package com.ydtech.modules.admin.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import com.ydtech.core.page.HttpResult; import com.ydtech.exception.SystemException; import com.ydtech.modules.admin.convert.SysUserConvert; import com.ydtech.modules.admin.model.SysCarousel; import com.ydtech.modules.admin.model.SysUser; import com.ydtech.modules.admin.service.SysCarouselService; import com.ydtech.modules.admin.service.SysUserService; import com.ydtech.modules.admin.vo.SysUserVO; import com.ydtech.modules.esm.convert.EsmUserInternalCheckConvert; import com.ydtech.modules.esm.convert.EsmUserInternalConvert; import com.ydtech.modules.esm.model.EsmOfferChannel; import com.ydtech.modules.esm.model.EsmUserInternal; import com.ydtech.modules.esm.model.EsmUserInternalCheck; import com.ydtech.modules.esm.model.SysUserCheck; import com.ydtech.modules.esm.service.EsmOfferChannelService; import com.ydtech.modules.esm.service.EsmUserInternalCheckService; import com.ydtech.modules.esm.service.EsmUserInternalService; import com.ydtech.modules.esm.service.SysUserCheckService; import com.ydtech.modules.esm.vo.EsmUserInternalVo; import com.ydtech.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; @Api(tags = "app端登录") @RestController @RequestMapping("/apps") public class AppLoginController{ @Autowired private EsmUserInternalCheckService esmUserInternalCheckService; @Autowired private SysUserService sysUserService; @Autowired private SysUserCheckService sysUserCheckService; @Autowired private EsmUserInternalService esmUserInternalService; @Autowired private SysCarouselService sysCarouselService; @Autowired private EsmOfferChannelService esmOfferChannelService; @PostMapping("/certification") @ApiOperation("app端认证信息") @Transactional public HttpResult certification(@RequestBody EsmUserInternalVo record) { if (StringUtils.isNullOrEmpty(record.getId())) { return HttpResult.error("工号不能为空"); } SysUserCheck sysUserCheck = sysUserCheckService.selectByPk(record.getId()); EsmUserInternalCheck esmUserInternalCheck = esmUserInternalCheckService.selectByPk(record.getId()); EsmUserInternalCheck internalCheck = EsmUserInternalCheckConvert.INSTANCE.vo2Dto(record); EsmUserInternal internal = EsmUserInternalConvert.INSTANCE.vo2Dto(record); internal.setStatus("0"); internal.setIsteamleader("0"); internalCheck.setStatus("0"); internalCheck.setIsteamleader("0"); // 查询申请不为空,就是修改 if (esmUserInternalCheck != null) { Integer integer = esmUserInternalCheckService.updateSelective(internalCheck); Integer integer1 = esmUserInternalService.updateSelective(internal); if (integer == 1 && integer1 == 1) { return HttpResult.ok("修改成功"); } return HttpResult.ok("修改失败"); } SysUser sysUser = new SysUser(); sysUser.setSex(record.getSex()); sysUser.setId(record.getId()); sysUser.setName(record.getName()); SysUserCheck sysUserCheck1 = SysUserConvert.INSTANCE.dto2Check(sysUser); sysUserCheck1.setCheckid(sysUserCheck.getCheckid()); Integer integer2 = sysUserCheckService.updateSelective(sysUserCheck1); // 新注册的信息提交 Integer integer = sysUserService.updateSelective(sysUser); internalCheck.setCheckid(sysUserCheck.getCheckid()); Integer insert = esmUserInternalCheckService.insertSelective(internalCheck); Integer integer1 = esmUserInternalService.insertSelective(internal); if (insert == 1 && integer == 1 && integer1 == 1 && integer2 == 1) { return HttpResult.ok("保存成功"); } throw new SystemException("修改失败"); } @GetMapping("/getApplicationStatus") @ApiOperation("工号查询申请状态") public HttpResult getApplicationStatus(String jobNumber) { EsmUserInternalCheck esmUserInternalCheck = esmUserInternalCheckService.selectByPk(jobNumber); if (esmUserInternalCheck != null) { return HttpResult.ok("成功", esmUserInternalCheck.getStatus()); } return HttpResult.error("未提交认证信息"); } @GetMapping("/getApplicationInfo") @ApiOperation("获取申请信息") public HttpResult getApplicationInfo(String jobNumber) { EsmUserInternalCheck esmUserInternalCheck = esmUserInternalCheckService.selectByPk(jobNumber); if (esmUserInternalCheck != null) { EsmUserInternalVo esmUserInternalVo = EsmUserInternalCheckConvert.INSTANCE.dto2Vo(esmUserInternalCheck); SysUser sysUser = sysUserService.selectByPk(jobNumber); esmUserInternalVo.setSex(sysUser.getSex()); esmUserInternalVo.setName(sysUser.getName()); return HttpResult.ok("成功", esmUserInternalVo); } return HttpResult.error("未提交认证信息"); } @GetMapping("/getCarousel") public HttpResult getCarousel() { QueryWrapper objectQueryWrapper = new QueryWrapper().eq("is_enable", 1).orderByAsc("sort"); List list = sysCarouselService.list(objectQueryWrapper); return HttpResult.ok(list); } @GetMapping("/getOfferChannel") public HttpResult getOfferChannel() { List esmOfferChannels = esmOfferChannelService.query().eq("is_open", 1).list(); return HttpResult.ok(esmOfferChannels); } }