feat: 改为移动端用户一键签到
This commit is contained in:
@@ -18,14 +18,18 @@ import com.ruoyi.cms.mapper.OutdoorFairJobMapper;
|
||||
import com.ruoyi.cms.domain.rc.PublicJobFair;
|
||||
import com.ruoyi.cms.domain.rc.PublicJobFairQuery;
|
||||
import com.ruoyi.cms.domain.rc.PublicJobFairResponse;
|
||||
import com.ruoyi.cms.service.IAppUserService;
|
||||
import com.ruoyi.cms.service.IOutdoorFairAttendeeService;
|
||||
import com.ruoyi.cms.service.IOutdoorFairService;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.common.annotation.BussinessLog;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.RequestUrlUtils;
|
||||
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -33,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -83,6 +86,9 @@ public class AppOutdoorFairController extends BaseController
|
||||
@Autowired
|
||||
private IOutdoorFairAttendeeService outdoorFairAttendeeService;
|
||||
|
||||
@Autowired
|
||||
private IAppUserService appUserService;
|
||||
|
||||
@BussinessLog(title = "户外招聘会列表")
|
||||
@ApiOperation("分页查询户外招聘会列表")
|
||||
@GetMapping("/page")
|
||||
@@ -193,30 +199,50 @@ public class AppOutdoorFairController extends BaseController
|
||||
return AjaxResult.error("招聘会不存在");
|
||||
}
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("fair", buildPublicFairDetail(fair));
|
||||
Map<String, Object> publicFair = buildPublicFairDetail(fair);
|
||||
publicFair.put("checkedIn", hasCheckedIn(fairId));
|
||||
data.put("fair", publicFair);
|
||||
data.put("companies", buildPublicParticipatingCompanies(fairId));
|
||||
data.put("fairH5Url", buildFairH5Url(request, fairId));
|
||||
return success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 匿名签到(姓名+手机号)。H5 企业页调用,无需登录。
|
||||
* 当前登录移动端用户一键签到。
|
||||
*/
|
||||
@BussinessLog(title = "户外招聘会企业H5签到")
|
||||
@ApiOperation("匿名签到(姓名+手机号)")
|
||||
@BussinessLog(title = "户外招聘会移动端签到")
|
||||
@ApiOperation("移动端用户一键签到")
|
||||
@PostMapping("/check-in")
|
||||
public AjaxResult checkIn(@RequestBody OutdoorFairAttendee attendee)
|
||||
public AjaxResult checkIn(@RequestParam Long fairId)
|
||||
{
|
||||
if (attendee.getFairId() == null) {
|
||||
if (!SiteSecurityUtils.isLogin()) {
|
||||
return AjaxResult.error("请先登录");
|
||||
}
|
||||
return checkIn(fairId, SiteSecurityUtils.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到业务实现单独保留 userId 入参,便于无 Web 容器的单元测试覆盖业务规则。
|
||||
*/
|
||||
AjaxResult checkIn(Long fairId, Long userId)
|
||||
{
|
||||
if (fairId == null) {
|
||||
return AjaxResult.error("缺少招聘会参数");
|
||||
}
|
||||
if (StringUtils.isBlank(attendee.getName())) {
|
||||
return AjaxResult.error("姓名不能为空");
|
||||
if (userId == null) {
|
||||
return AjaxResult.error("用户信息不存在,请重新登录");
|
||||
}
|
||||
if (StringUtils.isBlank(attendee.getPhone())) {
|
||||
return AjaxResult.error("手机号不能为空");
|
||||
AppUser appUser = appUserService.selectAppUserByUserId(userId);
|
||||
if (appUser == null || !"0".equals(appUser.getDelFlag())) {
|
||||
return AjaxResult.error("用户信息不存在,请重新登录");
|
||||
}
|
||||
OutdoorFair fair = outdoorFairService.getById(attendee.getFairId());
|
||||
if (!StringUtil.IS_JOB_REQUEST_USER.equals(appUser.getIsCompanyUser())) {
|
||||
return AjaxResult.error("仅移动端求职者可以签到");
|
||||
}
|
||||
if (StringUtils.isBlank(appUser.getName())) {
|
||||
return AjaxResult.error("请先完善移动端用户姓名");
|
||||
}
|
||||
OutdoorFair fair = outdoorFairService.getById(fairId);
|
||||
if (fair == null) {
|
||||
return AjaxResult.error("招聘会不存在");
|
||||
}
|
||||
@@ -226,13 +252,20 @@ public class AppOutdoorFairController extends BaseController
|
||||
if (!hasFairStarted(fair, new Date())) {
|
||||
return AjaxResult.error("招聘会还没有开始,暂不能签到");
|
||||
}
|
||||
// 同一招聘会下同手机号已签到则不重复记录
|
||||
// 同一招聘会下同一移动端用户已签到则不重复记录
|
||||
Long exists = outdoorFairAttendeeService.count(new LambdaQueryWrapper<OutdoorFairAttendee>()
|
||||
.eq(OutdoorFairAttendee::getFairId, attendee.getFairId())
|
||||
.eq(OutdoorFairAttendee::getPhone, attendee.getPhone()));
|
||||
.eq(OutdoorFairAttendee::getFairId, fairId)
|
||||
.eq(OutdoorFairAttendee::getUserId, userId));
|
||||
if (exists != null && exists > 0) {
|
||||
return AjaxResult.error("该手机号已签到");
|
||||
return AjaxResult.error("您已签到,无需重复签到");
|
||||
}
|
||||
OutdoorFairAttendee attendee = new OutdoorFairAttendee();
|
||||
attendee.setFairId(fairId);
|
||||
attendee.setUserId(userId);
|
||||
attendee.setName(appUser.getName());
|
||||
attendee.setPhone(appUser.getPhone());
|
||||
attendee.setAddress(StringUtils.isNotBlank(appUser.getAddress())
|
||||
? appUser.getAddress() : appUser.getDomicileAddress());
|
||||
attendee.setCheckInTime(new Date());
|
||||
return toAjax(outdoorFairAttendeeService.save(attendee));
|
||||
}
|
||||
@@ -243,6 +276,23 @@ public class AppOutdoorFairController extends BaseController
|
||||
&& !currentTime.before(fair.getHoldTime());
|
||||
}
|
||||
|
||||
private boolean hasCheckedIn(Long fairId)
|
||||
{
|
||||
if (!SiteSecurityUtils.isLogin()) {
|
||||
return false;
|
||||
}
|
||||
Long userId;
|
||||
try {
|
||||
userId = SiteSecurityUtils.getUserId();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
Long count = outdoorFairAttendeeService.count(new LambdaQueryWrapper<OutdoorFairAttendee>()
|
||||
.eq(OutdoorFairAttendee::getFairId, fairId)
|
||||
.eq(OutdoorFairAttendee::getUserId, userId));
|
||||
return count != null && count > 0;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildCompanyPage(Long fairId, Long companyId, OutdoorFairDevice device,
|
||||
HttpServletRequest request)
|
||||
{
|
||||
|
||||
@@ -3,13 +3,21 @@ package com.ruoyi.cms.controller.cms;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.cms.domain.OutdoorFair;
|
||||
import com.ruoyi.cms.domain.OutdoorFairAttendee;
|
||||
import com.ruoyi.cms.domain.vo.OutdoorFairAttendeeUserOption;
|
||||
import com.ruoyi.cms.service.IAppUserService;
|
||||
import com.ruoyi.cms.service.IOutdoorFairAttendeeService;
|
||||
import com.ruoyi.cms.service.IOutdoorFairService;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -37,6 +45,12 @@ public class OutdoorFairAttendeeController extends BaseController
|
||||
@Autowired
|
||||
private IOutdoorFairAttendeeService outdoorFairAttendeeService;
|
||||
|
||||
@Autowired
|
||||
private IOutdoorFairService outdoorFairService;
|
||||
|
||||
@Autowired
|
||||
private IAppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 查询签到人员列表(支持按人员姓名、手机号模糊查询)
|
||||
*/
|
||||
@@ -50,6 +64,22 @@ public class OutdoorFairAttendeeController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前招聘会尚未签到的移动端求职者。
|
||||
*/
|
||||
@ApiOperation("查询可录入签到的移动端用户")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:add')")
|
||||
@GetMapping("/available-users")
|
||||
public AjaxResult availableUsers(Long fairId, String keyword)
|
||||
{
|
||||
if (fairId == null) {
|
||||
return AjaxResult.error("缺少招聘会参数");
|
||||
}
|
||||
List<OutdoorFairAttendeeUserOption> list = outdoorFairAttendeeService
|
||||
.selectAvailableUserOptions(fairId, keyword);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到人员详细信息
|
||||
*/
|
||||
@@ -70,7 +100,42 @@ public class OutdoorFairAttendeeController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody OutdoorFairAttendee attendee)
|
||||
{
|
||||
return toAjax(outdoorFairAttendeeService.save(attendee));
|
||||
if (attendee == null || attendee.getFairId() == null) {
|
||||
return AjaxResult.error("缺少招聘会参数");
|
||||
}
|
||||
if (attendee.getUserId() == null) {
|
||||
return AjaxResult.error("请选择移动端用户");
|
||||
}
|
||||
OutdoorFair fair = outdoorFairService.getById(attendee.getFairId());
|
||||
if (fair == null) {
|
||||
return AjaxResult.error("招聘会不存在");
|
||||
}
|
||||
AppUser appUser = appUserService.selectAppUserByUserId(attendee.getUserId());
|
||||
if (appUser == null || !"0".equals(appUser.getDelFlag())) {
|
||||
return AjaxResult.error("移动端用户不存在或已删除");
|
||||
}
|
||||
if (!StringUtil.IS_JOB_REQUEST_USER.equals(appUser.getIsCompanyUser())) {
|
||||
return AjaxResult.error("只能录入移动端求职者");
|
||||
}
|
||||
if (StringUtils.isBlank(appUser.getName())) {
|
||||
return AjaxResult.error("移动端用户姓名为空,无法签到");
|
||||
}
|
||||
Long exists = outdoorFairAttendeeService.count(new LambdaQueryWrapper<OutdoorFairAttendee>()
|
||||
.eq(OutdoorFairAttendee::getFairId, attendee.getFairId())
|
||||
.eq(OutdoorFairAttendee::getUserId, attendee.getUserId()));
|
||||
if (exists != null && exists > 0) {
|
||||
return AjaxResult.error("该用户已签到");
|
||||
}
|
||||
|
||||
OutdoorFairAttendee record = new OutdoorFairAttendee();
|
||||
record.setFairId(attendee.getFairId());
|
||||
record.setUserId(appUser.getUserId());
|
||||
record.setName(appUser.getName());
|
||||
record.setPhone(appUser.getPhone());
|
||||
record.setAddress(StringUtils.isNotBlank(appUser.getAddress())
|
||||
? appUser.getAddress() : appUser.getDomicileAddress());
|
||||
record.setCheckInTime(new java.util.Date());
|
||||
return toAjax(outdoorFairAttendeeService.save(record));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,9 @@ public class OutdoorFairAttendee extends BaseEntity
|
||||
/** 招聘会ID */
|
||||
private Long fairId;
|
||||
|
||||
/** 移动端用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 人员姓名 */
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.cms.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 户外招聘会后台录入签到人员时使用的移动端用户选项。
|
||||
*/
|
||||
@Data
|
||||
public class OutdoorFairAttendeeUserOption
|
||||
{
|
||||
/** 移动端用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 用户名称 */
|
||||
private String name;
|
||||
|
||||
/** 手机号 */
|
||||
private String phone;
|
||||
|
||||
/** 用户地址 */
|
||||
private String address;
|
||||
}
|
||||
@@ -2,10 +2,24 @@ package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.OutdoorFairAttendee;
|
||||
import com.ruoyi.cms.domain.vo.OutdoorFairAttendeeUserOption;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 户外招聘会签到人员 Mapper。
|
||||
*/
|
||||
public interface OutdoorFairAttendeeMapper extends BaseMapper<OutdoorFairAttendee>
|
||||
{
|
||||
/**
|
||||
* 查询签到人员列表。关联移动端用户后,优先返回用户当前信息。
|
||||
*/
|
||||
List<OutdoorFairAttendee> selectAttendeeList(@Param("query") OutdoorFairAttendee query);
|
||||
|
||||
/**
|
||||
* 查询当前招聘会尚未签到的移动端求职者。
|
||||
*/
|
||||
List<OutdoorFairAttendeeUserOption> selectAvailableUserOptions(@Param("fairId") Long fairId,
|
||||
@Param("keyword") String keyword);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.cms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cms.domain.OutdoorFairAttendee;
|
||||
import com.ruoyi.cms.domain.vo.OutdoorFairAttendeeUserOption;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,4 +15,9 @@ public interface IOutdoorFairAttendeeService extends IService<OutdoorFairAttende
|
||||
* 查询签到人员列表(支持按人员姓名、手机号模糊查询)。
|
||||
*/
|
||||
List<OutdoorFairAttendee> selectAttendeeList(OutdoorFairAttendee query);
|
||||
|
||||
/**
|
||||
* 查询当前招聘会尚未签到的移动端求职者。
|
||||
*/
|
||||
List<OutdoorFairAttendeeUserOption> selectAvailableUserOptions(Long fairId, String keyword);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.OutdoorFairAttendee;
|
||||
import com.ruoyi.cms.domain.vo.OutdoorFairAttendeeUserOption;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairAttendeeMapper;
|
||||
import com.ruoyi.cms.service.IOutdoorFairAttendeeService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -21,12 +20,12 @@ public class OutdoorFairAttendeeServiceImpl
|
||||
@Override
|
||||
public List<OutdoorFairAttendee> selectAttendeeList(OutdoorFairAttendee query)
|
||||
{
|
||||
LambdaQueryWrapper<OutdoorFairAttendee> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(query.getFairId() != null, OutdoorFairAttendee::getFairId, query.getFairId());
|
||||
wrapper.like(StringUtils.isNotBlank(query.getName()), OutdoorFairAttendee::getName, query.getName());
|
||||
wrapper.like(StringUtils.isNotBlank(query.getPhone()), OutdoorFairAttendee::getPhone, query.getPhone());
|
||||
wrapper.orderByDesc(OutdoorFairAttendee::getCheckInTime);
|
||||
wrapper.orderByDesc(OutdoorFairAttendee::getId);
|
||||
return list(wrapper);
|
||||
return baseMapper.selectAttendeeList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OutdoorFairAttendeeUserOption> selectAvailableUserOptions(Long fairId, String keyword)
|
||||
{
|
||||
return baseMapper.selectAvailableUserOptions(fairId, keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.cms.mapper.OutdoorFairAttendeeMapper">
|
||||
|
||||
<resultMap id="OutdoorFairAttendeeResult"
|
||||
type="com.ruoyi.cms.domain.OutdoorFairAttendee">
|
||||
<id property="id" column="id"/>
|
||||
<result property="fairId" column="fair_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="address" column="address"/>
|
||||
<result property="checkInTime" column="check_in_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="OutdoorFairAttendeeUserOptionResult"
|
||||
type="com.ruoyi.cms.domain.vo.OutdoorFairAttendeeUserOption">
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="address" column="address"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAttendeeList"
|
||||
parameterType="com.ruoyi.cms.domain.OutdoorFairAttendee"
|
||||
resultMap="OutdoorFairAttendeeResult">
|
||||
SELECT a.id,
|
||||
a.fair_id,
|
||||
a.user_id,
|
||||
COALESCE(NULLIF(u.name, ''), a.name) AS name,
|
||||
COALESCE(NULLIF(u.phone, ''), a.phone) AS phone,
|
||||
COALESCE(NULLIF(u.address, ''), NULLIF(u.domicile_address, ''), a.address) AS address,
|
||||
a.check_in_time,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.remark,
|
||||
a.del_flag
|
||||
FROM shz.cms_outdoor_fair_attendee a
|
||||
LEFT JOIN app_user u ON u.user_id = a.user_id AND u.del_flag = '0'
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="query != null and query.fairId != null">
|
||||
AND a.fair_id = #{query.fairId}
|
||||
</if>
|
||||
<if test="query != null and query.name != null and query.name != ''">
|
||||
AND COALESCE(NULLIF(u.name, ''), a.name) LIKE CONCAT('%', CAST(#{query.name} AS VARCHAR), '%')
|
||||
</if>
|
||||
<if test="query != null and query.phone != null and query.phone != ''">
|
||||
AND COALESCE(NULLIF(u.phone, ''), a.phone) LIKE CONCAT('%', CAST(#{query.phone} AS VARCHAR), '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.check_in_time DESC, a.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectAvailableUserOptions"
|
||||
resultMap="OutdoorFairAttendeeUserOptionResult">
|
||||
SELECT u.user_id,
|
||||
u.name,
|
||||
u.phone,
|
||||
COALESCE(u.address, u.domicile_address) AS address
|
||||
FROM app_user u
|
||||
WHERE u.del_flag = '0'
|
||||
AND u.is_company_user = '1'
|
||||
AND NULLIF(u.name, '') IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM shz.cms_outdoor_fair_attendee a
|
||||
WHERE a.fair_id = #{fairId}
|
||||
AND a.user_id = u.user_id
|
||||
AND a.del_flag = '0'
|
||||
)
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
u.name LIKE CONCAT('%', CAST(#{keyword} AS VARCHAR), '%')
|
||||
OR u.phone LIKE CONCAT('%', CAST(#{keyword} AS VARCHAR), '%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY u.name ASC NULLS LAST, u.user_id ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -9,10 +9,13 @@ import com.ruoyi.cms.mapper.OutdoorFairBoothBookingMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairJobMapper;
|
||||
import com.ruoyi.cms.service.IOutdoorFairAttendeeService;
|
||||
import com.ruoyi.cms.service.IAppUserService;
|
||||
import com.ruoyi.cms.service.IOutdoorFairService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -37,11 +40,13 @@ class AppOutdoorFairControllerTest
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
OutdoorFair fair = fairAt(new Date(System.currentTimeMillis() + 60_000L));
|
||||
when(fairService.getById(12L)).thenReturn(fair);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService);
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser());
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(attendee(12L));
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(500, result.get(AjaxResult.CODE_TAG));
|
||||
assertEquals("招聘会还没有开始,暂不能签到", result.get(AjaxResult.MSG_TAG));
|
||||
@@ -53,10 +58,12 @@ class AppOutdoorFairControllerTest
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
when(fairService.getById(12L)).thenReturn(fairAt(null));
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService);
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser());
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(attendee(12L));
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(500, result.get(AjaxResult.CODE_TAG));
|
||||
assertEquals("招聘会还没有开始,暂不能签到", result.get(AjaxResult.MSG_TAG));
|
||||
@@ -68,13 +75,15 @@ class AppOutdoorFairControllerTest
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
OutdoorFair fair = fairAt(new Date(System.currentTimeMillis() - 1_000L));
|
||||
when(fairService.getById(12L)).thenReturn(fair);
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser());
|
||||
when(attendeeService.count(any())).thenReturn(0L);
|
||||
when(attendeeService.save(any(OutdoorFairAttendee.class))).thenReturn(true);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(attendee(12L));
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(200, result.get(AjaxResult.CODE_TAG));
|
||||
verify(attendeeService).save(any(OutdoorFairAttendee.class));
|
||||
@@ -83,6 +92,72 @@ class AppOutdoorFairControllerTest
|
||||
fair, new Date(fair.getHoldTime().getTime() - 1L)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkInUsesCurrentMobileUserProfile() throws Exception
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
OutdoorFair fair = fairAt(new Date(System.currentTimeMillis() - 1_000L));
|
||||
AppUser appUser = appUser();
|
||||
appUser.setAddress("石河子市测试地址");
|
||||
when(fairService.getById(12L)).thenReturn(fair);
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser);
|
||||
when(attendeeService.count(any())).thenReturn(0L);
|
||||
when(attendeeService.save(any(OutdoorFairAttendee.class))).thenReturn(true);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(200, result.get(AjaxResult.CODE_TAG));
|
||||
ArgumentCaptor<OutdoorFairAttendee> captor = ArgumentCaptor.forClass(OutdoorFairAttendee.class);
|
||||
verify(attendeeService).save(captor.capture());
|
||||
OutdoorFairAttendee record = captor.getValue();
|
||||
assertEquals(12L, record.getFairId());
|
||||
assertEquals(99L, record.getUserId());
|
||||
assertEquals("测试人员", record.getName());
|
||||
assertEquals("13800000000", record.getPhone());
|
||||
assertEquals("石河子市测试地址", record.getAddress());
|
||||
assertTrue(record.getCheckInTime() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void duplicateUserCannotCheckInAgain() throws Exception
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
when(fairService.getById(12L)).thenReturn(fairAt(new Date(System.currentTimeMillis() - 1_000L)));
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser());
|
||||
when(attendeeService.count(any())).thenReturn(1L);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(500, result.get(AjaxResult.CODE_TAG));
|
||||
assertEquals("您已签到,无需重复签到", result.get(AjaxResult.MSG_TAG));
|
||||
verify(attendeeService, never()).save(any(OutdoorFairAttendee.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonJobSeekerCannotCheckIn() throws Exception
|
||||
{
|
||||
IOutdoorFairService fairService = mock(IOutdoorFairService.class);
|
||||
IOutdoorFairAttendeeService attendeeService = mock(IOutdoorFairAttendeeService.class);
|
||||
IAppUserService appUserService = mock(IAppUserService.class);
|
||||
AppUser appUser = appUser();
|
||||
appUser.setIsCompanyUser("0");
|
||||
when(appUserService.selectAppUserByUserId(99L)).thenReturn(appUser);
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService, appUserService);
|
||||
|
||||
AjaxResult result = controller.checkIn(12L, 99L);
|
||||
|
||||
assertEquals(500, result.get(AjaxResult.CODE_TAG));
|
||||
assertEquals("仅移动端求职者可以签到", result.get(AjaxResult.MSG_TAG));
|
||||
verify(fairService, never()).getById(12L);
|
||||
verify(attendeeService, never()).save(any(OutdoorFairAttendee.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void publicDetailIncludesOnlySafeCompanyCardFields() throws Exception
|
||||
@@ -144,6 +219,17 @@ class AppOutdoorFairControllerTest
|
||||
AppOutdoorFairController controller = new AppOutdoorFairController();
|
||||
setField(controller, "outdoorFairService", fairService);
|
||||
setField(controller, "outdoorFairAttendeeService", attendeeService);
|
||||
setField(controller, "appUserService", mock(IAppUserService.class));
|
||||
return controller;
|
||||
}
|
||||
|
||||
private AppOutdoorFairController controllerWith(IOutdoorFairService fairService,
|
||||
IOutdoorFairAttendeeService attendeeService,
|
||||
IAppUserService appUserService)
|
||||
throws Exception
|
||||
{
|
||||
AppOutdoorFairController controller = controllerWith(fairService, attendeeService);
|
||||
setField(controller, "appUserService", appUserService);
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -154,13 +240,15 @@ class AppOutdoorFairControllerTest
|
||||
field.set(target, value);
|
||||
}
|
||||
|
||||
private OutdoorFairAttendee attendee(Long fairId)
|
||||
private AppUser appUser()
|
||||
{
|
||||
OutdoorFairAttendee attendee = new OutdoorFairAttendee();
|
||||
attendee.setFairId(fairId);
|
||||
attendee.setName("测试人员");
|
||||
attendee.setPhone("13800000000");
|
||||
return attendee;
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setUserId(99L);
|
||||
appUser.setName("测试人员");
|
||||
appUser.setPhone("13800000000");
|
||||
appUser.setIsCompanyUser("1");
|
||||
appUser.setDelFlag("0");
|
||||
return appUser;
|
||||
}
|
||||
|
||||
private OutdoorFair fairAt(Date holdTime)
|
||||
|
||||
Reference in New Issue
Block a user