添加后端企业浏览求职者简历接口
This commit is contained in:
@@ -0,0 +1,74 @@
|
|||||||
|
package com.ruoyi.cms.controller.cms;
|
||||||
|
|
||||||
|
import com.ruoyi.cms.domain.msg.HrUserBehaviorRecord;
|
||||||
|
import com.ruoyi.cms.service.msg.HrUserBehaviorRecordService;
|
||||||
|
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.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cms/behavior")
|
||||||
|
@Api(tags = "后台:行为记录")
|
||||||
|
public class CmsHrUserBehaviorRecordController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HrUserBehaviorRecordService hrUserBehaviorRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询行为记录列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
@PreAuthorize("@ss.hasPermi('cms:behavior:list')")
|
||||||
|
@ApiOperation("查询行为记录列表")
|
||||||
|
public TableDataInfo list(HrUserBehaviorRecord hrUserBehaviorRecord) {
|
||||||
|
if (!SiteSecurityUtils.isLogin()) {
|
||||||
|
throw new ServiceException("用户未登录");
|
||||||
|
}
|
||||||
|
Long userId = SiteSecurityUtils.getUserId();
|
||||||
|
boolean admin = SiteSecurityUtils.isAdmin(userId);
|
||||||
|
if (!admin) {
|
||||||
|
hrUserBehaviorRecord.setActorId(userId);
|
||||||
|
} else {
|
||||||
|
hrUserBehaviorRecord.setActorId(null);
|
||||||
|
}
|
||||||
|
startPage();
|
||||||
|
List<HrUserBehaviorRecord> list = hrUserBehaviorRecordService.selectBehaviorRecordList(hrUserBehaviorRecord);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上报浏览行为/投递行为
|
||||||
|
*/
|
||||||
|
@ApiOperation("上报浏览行为/投递行为")
|
||||||
|
@PreAuthorize("@ss.hasPermi('cms:behavior:report')")
|
||||||
|
@Log(title = "用户培训经历", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("/report")
|
||||||
|
public AjaxResult reportBehavior(@RequestBody HrUserBehaviorRecord record) {
|
||||||
|
HrUserBehaviorRecord exist = hrUserBehaviorRecordService.getExistViewRecord(
|
||||||
|
record.getActorType(),
|
||||||
|
record.getActorId(),
|
||||||
|
record.getTargetType(),
|
||||||
|
record.getTargetId()
|
||||||
|
);
|
||||||
|
if (exist == null) {
|
||||||
|
record.setViewNum(1);
|
||||||
|
hrUserBehaviorRecordService.save(record);
|
||||||
|
} else {
|
||||||
|
exist.setViewNum(exist.getViewNum() + 1);
|
||||||
|
exist.setViewDuration(exist.getViewDuration() + record.getViewDuration());
|
||||||
|
hrUserBehaviorRecordService.updateById(exist);
|
||||||
|
}
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user