渲染题库列表,增加题库类型功能
This commit is contained in:
parent
b024e1a128
commit
7927a35ba9
|
@ -0,0 +1,59 @@
|
||||||
|
package com.yzdx.AiInterviewer.controller;
|
||||||
|
|
||||||
|
import com.yzdx.AiInterviewer.comment.R;
|
||||||
|
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||||
|
import com.yzdx.AiInterviewer.service.QuestionBankService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/question")
|
||||||
|
public class QuestionController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private QuestionBankService questionBankService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取题库列表
|
||||||
|
* @param encoding 公司编码
|
||||||
|
* @return 返回的该公司下的公司题库
|
||||||
|
* */
|
||||||
|
@GetMapping("/get_typeList")
|
||||||
|
public R getTypeListByEncoding(@RequestParam Integer encoding){
|
||||||
|
|
||||||
|
List<QuestionBank> typeList = questionBankService.getTypeList(encoding);
|
||||||
|
|
||||||
|
return R.success(typeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param addInfo typeName,encoding,userId
|
||||||
|
* @return R
|
||||||
|
* */
|
||||||
|
@PostMapping("/add_typeName")
|
||||||
|
public R addTypeName(@RequestBody Map<String ,Object> addInfo){
|
||||||
|
|
||||||
|
if(addInfo.size()==0){
|
||||||
|
return R.error("添加失败,请检查输入");
|
||||||
|
}
|
||||||
|
String typeName=(String)addInfo.get("typeName");
|
||||||
|
Integer encoding= Integer.parseInt((String)addInfo.get("encoding"));
|
||||||
|
Integer userId=(Integer)addInfo.get("userId");
|
||||||
|
|
||||||
|
Integer row=questionBankService.addTypeName(typeName,encoding,userId);
|
||||||
|
|
||||||
|
if(row==0){
|
||||||
|
return R.error("添加失败,请联系管理员");
|
||||||
|
}
|
||||||
|
if (row==-2){
|
||||||
|
return R.error("该题库类型已存在!");
|
||||||
|
}
|
||||||
|
return R.success("添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,8 @@ import com.yzdx.AiInterviewer.service.UserService;
|
||||||
import com.yzdx.AiInterviewer.utiles.JWT;
|
import com.yzdx.AiInterviewer.utiles.JWT;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpRequest;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,18 +30,31 @@ public class UserController {
|
||||||
return userService.adminLogin(phone, encoding, password);
|
return userService.adminLogin(phone, encoding, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getuserinfo")
|
@GetMapping("/get_userInfo")
|
||||||
public R getUserInfo(HttpServletRequest request) {
|
public R getUserInfo( @ApiParam("token值") String token) {
|
||||||
|
|
||||||
String Token = request.getHeader("Authorization");
|
if(token==null){
|
||||||
|
return R.error(401,"非法访问,请重新登陆!");
|
||||||
Integer userId = JWT.getTokenId(Token);
|
}
|
||||||
|
Integer userId = JWT.getTokenId(token);
|
||||||
|
|
||||||
User findUser = userService.getUserById(userId);
|
User findUser = userService.getUserById(userId);
|
||||||
if (findUser == null) {
|
if (findUser == null) {
|
||||||
return R.error(401, "非法访问,请重新登陆");
|
return R.error(401, "非法访问,请重新登陆");
|
||||||
}
|
}
|
||||||
return R.success(findUser);
|
User user=new User();
|
||||||
|
user.setId(findUser.getId());
|
||||||
|
user.setUsername(findUser.getUsername());
|
||||||
|
user.setRole(findUser.getRole());
|
||||||
|
user.setPhone(findUser.getPhone());
|
||||||
|
user.setSex(findUser.getSex());
|
||||||
|
user.setAge(findUser.getAge());
|
||||||
|
user.setAvatar(findUser.getAvatar());
|
||||||
|
user.setEmail(findUser.getEmail());
|
||||||
|
user.setCreateTime(findUser.getCreateTime());
|
||||||
|
user.setUpdateTime(findUser.getUpdateTime());
|
||||||
|
|
||||||
|
return R.success(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,12 @@ package com.yzdx.AiInterviewer.entity;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
@Data
|
@Data
|
||||||
public class BaseEntity {
|
public class BaseEntity {
|
||||||
@ApiModelProperty("电子邮箱")
|
@ApiModelProperty("电子邮箱")
|
||||||
private Date createTime;
|
private String createTime;
|
||||||
@ApiModelProperty("电子邮箱")
|
@ApiModelProperty("电子邮箱")
|
||||||
private Date updateTime;
|
private String updateTime;
|
||||||
@ApiModelProperty("电子邮箱")
|
@ApiModelProperty("电子邮箱")
|
||||||
private Integer createUser;
|
private Integer createUser;
|
||||||
@ApiModelProperty("电子邮箱")
|
@ApiModelProperty("电子邮箱")
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.yzdx.AiInterviewer.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Employee {
|
||||||
|
@ApiModelProperty("用户id")
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("手机号码")
|
||||||
|
private String phone;
|
||||||
|
@ApiModelProperty("电子邮箱")
|
||||||
|
private String email;
|
||||||
|
@ApiModelProperty("住址")
|
||||||
|
private String address;
|
||||||
|
@ApiModelProperty("入职日期")
|
||||||
|
private Date onboardDate;
|
||||||
|
@ApiModelProperty("部门id")
|
||||||
|
private Integer departmentId;
|
||||||
|
@ApiModelProperty("公司编码")
|
||||||
|
private Integer companyEncoding;
|
||||||
|
@ApiModelProperty("职位")
|
||||||
|
private String position;
|
||||||
|
@ApiModelProperty("上级id")
|
||||||
|
private Integer superior;
|
||||||
|
@ApiModelProperty("工资")
|
||||||
|
private Double salary;
|
||||||
|
@ApiModelProperty("绩效评分")
|
||||||
|
private Double performanceScore;
|
||||||
|
@ApiModelProperty("教育背景")
|
||||||
|
private String educationalBackground;
|
||||||
|
@ApiModelProperty("工作经历")
|
||||||
|
private String workExperience;
|
||||||
|
@ApiModelProperty("性别")
|
||||||
|
private String sex;
|
||||||
|
@ApiModelProperty("年龄")
|
||||||
|
private String age;
|
||||||
|
@ApiModelProperty("员工证件照")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.yzdx.AiInterviewer.entity;
|
||||||
|
|
||||||
|
public class Question {
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.yzdx.AiInterviewer.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ApiModel("题库实体类")
|
||||||
|
@Data
|
||||||
|
@TableName("question_bank")
|
||||||
|
public class QuestionBank extends BaseEntity{
|
||||||
|
@ApiModelProperty("题库id")
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
@ApiModelProperty("题库名称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("公司编码")
|
||||||
|
private Integer companyEncoding;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.yzdx.AiInterviewer.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.yzdx.AiInterviewer.entity.Employee;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface EmployeeMapper extends BaseMapper<Employee> {
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.yzdx.AiInterviewer.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface QuestionBankMapper extends BaseMapper<QuestionBank> {
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.yzdx.AiInterviewer.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface QuestionBankService extends IService<QuestionBank> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param encoding 公司编码
|
||||||
|
* @return List<QuestionBank> 题库列表
|
||||||
|
* */
|
||||||
|
List<QuestionBank> getTypeList(Integer encoding);
|
||||||
|
/**
|
||||||
|
* @param typeName,encoding,userId
|
||||||
|
* @return 返回影响行数
|
||||||
|
* */
|
||||||
|
Integer addTypeName(String typeName,Integer encoding,Integer userId);
|
||||||
|
/**
|
||||||
|
* @param typeNameId,encoding,userId
|
||||||
|
* @return 返回影响行数
|
||||||
|
* */
|
||||||
|
Integer deleteTypeName(Integer typeNameId,Integer encoding,Integer userId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.yzdx.AiInterviewer.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||||
|
import com.yzdx.AiInterviewer.mapper.QuestionBankMapper;
|
||||||
|
import com.yzdx.AiInterviewer.service.QuestionBankService;
|
||||||
|
import com.yzdx.AiInterviewer.utiles.TimeUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class QuestionBankServiceImpl extends ServiceImpl<QuestionBankMapper, QuestionBank> implements QuestionBankService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private QuestionBankMapper questionBankMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<QuestionBank> getTypeList(Integer encoding) {
|
||||||
|
//若公司编码为空,则返回空
|
||||||
|
if(encoding==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<QuestionBank> queryWrapper =new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq(QuestionBank::getCompanyEncoding,encoding);
|
||||||
|
|
||||||
|
List<QuestionBank> questionBanks= questionBankMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
return questionBanks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addTypeName(String typeName, Integer encoding, Integer userId) {
|
||||||
|
|
||||||
|
//判断题库名是否存在
|
||||||
|
LambdaQueryWrapper<QuestionBank> queryWrapper =new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(QuestionBank::getName,typeName);
|
||||||
|
QuestionBank findQuestionBank=questionBankMapper.selectOne(queryWrapper);
|
||||||
|
if(findQuestionBank!=null){
|
||||||
|
//存在返回-2
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestionBank insert=new QuestionBank();
|
||||||
|
insert.setName(typeName);
|
||||||
|
insert.setCompanyEncoding(encoding);
|
||||||
|
insert.setCreateUser(userId);
|
||||||
|
insert.setUpdateUser(userId);
|
||||||
|
insert.setCreateTime(TimeUtil.getTime());
|
||||||
|
insert.setUpdateTime(TimeUtil.getTime());
|
||||||
|
|
||||||
|
return questionBankMapper.insert(insert);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteTypeName(Integer typeNameId, Integer encoding, Integer userId) {
|
||||||
|
LambdaQueryWrapper<QuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq(QuestionBank::getId,typeNameId).eq(QuestionBank::getCompanyEncoding,encoding);
|
||||||
|
|
||||||
|
Integer row= questionBankMapper.deleteById(typeNameId);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yzdx.AiInterviewer.comment.R;
|
import com.yzdx.AiInterviewer.comment.R;
|
||||||
import com.yzdx.AiInterviewer.entity.Company;
|
import com.yzdx.AiInterviewer.entity.Company;
|
||||||
|
import com.yzdx.AiInterviewer.entity.Employee;
|
||||||
import com.yzdx.AiInterviewer.entity.User;
|
import com.yzdx.AiInterviewer.entity.User;
|
||||||
import com.yzdx.AiInterviewer.mapper.CompanyMapper;
|
import com.yzdx.AiInterviewer.mapper.CompanyMapper;
|
||||||
|
import com.yzdx.AiInterviewer.mapper.EmployeeMapper;
|
||||||
import com.yzdx.AiInterviewer.mapper.UserMapper;
|
import com.yzdx.AiInterviewer.mapper.UserMapper;
|
||||||
import com.yzdx.AiInterviewer.service.UserService;
|
import com.yzdx.AiInterviewer.service.UserService;
|
||||||
import com.yzdx.AiInterviewer.utiles.JWT;
|
import com.yzdx.AiInterviewer.utiles.JWT;
|
||||||
|
@ -25,9 +27,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||||
@Autowired
|
@Autowired
|
||||||
private CompanyMapper companyMapper;
|
private CompanyMapper companyMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmployeeMapper employeeMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R adminLogin(String phone, String encoding, String password) {
|
public R adminLogin(String phone, String encoding, String password) {
|
||||||
|
|
||||||
|
//判断员工是否在该公司
|
||||||
|
LambdaQueryWrapper<Employee> queryWrapper2=new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper2.eq(Employee::getPhone,phone).eq(Employee::getCompanyEncoding,encoding);
|
||||||
|
Employee findEmployee=employeeMapper.selectOne(queryWrapper2);
|
||||||
|
|
||||||
|
if(findEmployee==null){
|
||||||
|
|
||||||
|
return R.error("输入的账号或密码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LambdaQueryWrapper<User> queryWrapper=new LambdaQueryWrapper();
|
LambdaQueryWrapper<User> queryWrapper=new LambdaQueryWrapper();
|
||||||
|
|
||||||
queryWrapper.eq(User::getPhone,phone);
|
queryWrapper.eq(User::getPhone,phone);
|
||||||
|
@ -70,6 +86,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||||
Map<String,Object> data=new HashMap<>();
|
Map<String,Object> data=new HashMap<>();
|
||||||
|
|
||||||
data.put("token",token);
|
data.put("token",token);
|
||||||
|
data.put("encoding",encoding);
|
||||||
|
|
||||||
return R.success(data);
|
return R.success(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.yzdx.AiInterviewer.utiles;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class TimeUtil {
|
||||||
|
|
||||||
|
public static String getTime(){
|
||||||
|
Date now =new Date();
|
||||||
|
|
||||||
|
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
String time = simpleDateFormat.format(now);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue