添加教师库部分

main
王家东 3 months ago
parent c85c2d49dc
commit d5fd46fa93
  1. 351
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/controller/SeteacherController.java
  2. 102
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/entity/Seteacher.java
  3. 17
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/mapper/SeteacherMapper.java
  4. 5
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/mapper/xml/SeteacherMapper.xml
  5. 14
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/service/ISeteacherService.java
  6. 19
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/seteacher/service/impl/SeteacherServiceImpl.java

@ -0,0 +1,351 @@
package org.jeecg.modules.demo.seteacher.controller;
import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.demo.compexp.entity.CompExp;
import org.jeecg.modules.demo.expert.entity.Expert;
import org.jeecg.modules.demo.seteacher.entity.Seteacher;
import org.jeecg.modules.demo.seteacher.service.ISeteacherService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.service.ISysDictService;
import org.jeecg.modules.system.service.ISysRoleService;
import org.jeecg.modules.system.service.ISysUserRoleService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: seteacher
* @Author: jeecg-boot
* @Date: 2024-08-23
* @Version: V1.0
*/
@Api(tags="seteacher")
@RestController
@RequestMapping("/seteacher/seteacher")
@Slf4j
public class SeteacherController extends JeecgController<Seteacher, ISeteacherService> {
@Autowired
private ISeteacherService seteacherService;
@Autowired
private BaseCommonService baseCommonService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysUserRoleService sysUserRoleService;
@Autowired
private ISysRoleService sysRoleService;
@Autowired
private ISysDictService sysDictService;
/**
* 分页列表查询
*
* @param seteacher
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "seteacher-分页列表查询")
@ApiOperation(value="seteacher-分页列表查询", notes="seteacher-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<Seteacher>> queryPageList(Seteacher seteacher,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<Seteacher> queryWrapper = QueryGenerator.initQueryWrapper(seteacher, req.getParameterMap());
Page<Seteacher> page = new Page<Seteacher>(pageNo, pageSize);
IPage<Seteacher> pageList = seteacherService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加教师信息
*
* @param seteacher
* @return
*/
@AutoLog(value = "seteacher-添加")
@ApiOperation(value="seteacher-添加", notes="seteacher-添加")
@RequiresPermissions("seteacher:seteacher:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody Seteacher seteacher) {
seteacherService.save(seteacher);
return Result.OK("添加成功!");
}
@RequestMapping(value = "/addTEA", method = RequestMethod.POST)
public Result<SysUser> addZJ(@RequestBody JSONObject jsonObject) {
LoginUser userss= (LoginUser) SecurityUtils.getSubject().getPrincipal();
//设置部门
String selectedDeparts ="";
//根据user查找角色
String roles = getRoleByUserId(userss.getId());
//如果是学校管理员就就找到当前设置的院系,如果是院系管理员就直接获取所在院系
if (roles.equals("superAdmin")){
selectedDeparts = jsonObject.getString("selecteddeparts");
}else{
String roleid =findroles(userss);
selectedDeparts = roleid;
}
Result<SysUser> result = new Result<SysUser>();
// String selectedRoles = jsonObject.getString("selectedroles");
String selectedRoles = "1731948288626339844";
String expSc = jsonObject.getString("expSc");
String expResume = jsonObject.getString("expResume");//简介
String expTitle = jsonObject.getString("expTitle");
String teamajor = jsonObject.getString("teamajor");//专业
String expXw = jsonObject.getString("expXw");//学位
String expZc = jsonObject.getString("expZc");//职称
String expYjfx = jsonObject.getString("expYjfx");//研究方向
String expCsgz = jsonObject.getString("expCsgz");//从事工作
try {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setCreateTime(new Date());//设置创建时间
String salt = oConvertUtils.randomGen(8);
user.setSalt(salt);
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), salt);
user.setPassword(passwordEncode);
user.setStatus(1);
user.setDelFlag(CommonConstant.DEL_FLAG_0);
//用户表字段org_code不能在这里设置他的值
user.setOrgCode(null);
// 保存用户走一个service 保证事务
//获取租户ids
String relTenantIds = jsonObject.getString("relTenantIds");
sysUserService.saveUser(user, selectedRoles, selectedDeparts, relTenantIds);
baseCommonService.addLog("添加专家用户,username: " +user.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
Seteacher expert = new Seteacher();
expert.setUserId(user.getId());
expert.setExpImg(user.getAvatar());
expert.setExpSc(expSc);
expert.setExpResume(expResume);
expert.setExpTitle(expTitle);
expert.setName(user.getRealname());
expert.setExpXw(expXw);//学位
expert.setExpZc(expZc);//职称
expert.setExpYjfx(expYjfx);//研究方向
expert.setExpCsgz(expCsgz);//从事工作
expert.setTeamajor(teamajor);//专业
seteacherService.save(expert);
result.success("添加成功!");
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败");
}
return result;
}
//用于当前登录信息的部门设置
private String findroles(LoginUser userss) {
SysDict sysDict = sysDictService.query().eq("org_code",userss.getOrgCode()).one();
return sysDict.getId();
}
/**
* 1.2根据用户id获取用户角色信息
*
* @param userId
* @return
*/
public String getRoleByUserId(String userId) {
SysUserRole userRoleList = sysUserRoleService.query().eq("user_id", userId).one();
SysRole sysRole = sysRoleService.getById(userRoleList.getRoleId());
return sysRole.getRoleCode();
}
@RequestMapping(value = "/editTEA", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<SysUser> editZJ(@RequestBody JSONObject jsonObject,HttpServletRequest req) {
Result<SysUser> result = new Result<SysUser>();
try {
SysUser sysUser = sysUserService.getById(jsonObject.getString("id"));
baseCommonService.addLog("编辑用户,username: " +sysUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
if(sysUser==null) {
result.error500("未找到对应实体");
}else {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setUpdateTime(new Date());
//String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
user.setPassword(sysUser.getPassword());
String roles = "1731948288626339844";
String departs = jsonObject.getString("selecteddeparts");
String expSc = jsonObject.getString("expSc");
String expResume = jsonObject.getString("expResume");
String expTitle = jsonObject.getString("expTitle");
String teamajor =jsonObject.getString("teamajor");
String expXw = jsonObject.getString("expXw");//学位
String expZc = jsonObject.getString("expZc");//职称
String expYjfx = jsonObject.getString("expYjfx");//研究方向
String expCsgz = jsonObject.getString("expCsgz");//从事工作
if(oConvertUtils.isEmpty(departs)){
//vue3.0前端只传递了departIds
departs=user.getDepartIds();
}
//用户表字段org_code不能在这里设置他的值
user.setOrgCode(null);
// 修改用户走一个service 保证事务
//获取租户ids
String relTenantIds = jsonObject.getString("relTenantIds");
sysUserService.editUser(user, roles, departs, relTenantIds);
Seteacher expert = new Seteacher();
QueryWrapper<Seteacher> queryWrapper = QueryGenerator.initQueryWrapper(expert, req.getParameterMap());
queryWrapper.eq("user_id",user.getId());
List<Seteacher> listex = seteacherService.list(queryWrapper);
expert = listex.get(0);
expert.setUserId(user.getId());
expert.setExpImg(user.getAvatar());
expert.setExpSc(expSc);
expert.setExpResume(expResume);
expert.setExpTitle(expTitle);
expert.setName(user.getRealname());
expert.setExpXw(expXw);//学位
expert.setTeamajor(teamajor);//专业
expert.setExpZc(expZc);//职称
expert.setExpYjfx(expYjfx);//研究方向
expert.setExpCsgz(expCsgz);//从事工作
seteacherService.updateById(expert);
result.success("修改成功!");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败");
}
return result;
}
/**
* 编辑
*
* @param seteacher
* @return
*/
@AutoLog(value = "seteacher-编辑")
@ApiOperation(value="seteacher-编辑", notes="seteacher-编辑")
@RequiresPermissions("seteacher:seteacher:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody Seteacher seteacher) {
seteacherService.updateById(seteacher);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "seteacher-通过id删除")
@ApiOperation(value="seteacher-通过id删除", notes="seteacher-通过id删除")
@RequiresPermissions("seteacher:seteacher:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
seteacherService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "seteacher-批量删除")
@ApiOperation(value="seteacher-批量删除", notes="seteacher-批量删除")
@RequiresPermissions("seteacher:seteacher:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.seteacherService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "seteacher-通过id查询")
@ApiOperation(value="seteacher-通过id查询", notes="seteacher-通过id查询")
@GetMapping(value = "/queryById")
public Result<Seteacher> queryById(@RequestParam(name="id",required=true) String id,HttpServletRequest req) {
Seteacher seteacher = new Seteacher();
QueryWrapper<Seteacher> queryWrapper = QueryGenerator.initQueryWrapper(seteacher, req.getParameterMap());
queryWrapper.eq("user_id",id);
seteacher=seteacherService.getOne(queryWrapper);
if(seteacher==null) {
return Result.error("未找到对应数据");
}
return Result.OK(seteacher);
}
/**
* 导出excel
*
* @param request
* @param seteacher
*/
@RequiresPermissions("seteacher:seteacher:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Seteacher seteacher) {
return super.exportXls(request, seteacher, Seteacher.class, "seteacher");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("seteacher:seteacher:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Seteacher.class);
}
}

@ -0,0 +1,102 @@
package org.jeecg.modules.demo.seteacher.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: seteacher
* @Author: jeecg-boot
* @Date: 2024-08-23
* @Version: V1.0
*/
@Data
@TableName("seteacher")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="seteacher对象", description="seteacher")
public class Seteacher implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
/**用户id*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
/**专家照片*/
@Excel(name = "专家照片", width = 15)
@ApiModelProperty(value = "专家照片")
private String expImg;
/**专家毕业院校*/
@Excel(name = "专家毕业院校", width = 15)
@ApiModelProperty(value = "专家毕业院校")
private String expSc;
/**简介*/
@Excel(name = "简介", width = 15)
@ApiModelProperty(value = "简介")
private String expResume;
/**专家学历*/
@Excel(name = "专家学历", width = 15)
@ApiModelProperty(value = "专家学历")
private String expTitle;
/**学位*/
@Excel(name = "学位", width = 15)
@ApiModelProperty(value = "学位")
private String expXw;
/**职称*/
@Excel(name = "职称", width = 15)
@ApiModelProperty(value = "职称")
private String expZc;
/**研究方向*/
@Excel(name = "研究方向", width = 15)
@ApiModelProperty(value = "研究方向")
private String expYjfx;
/**从事工作*/
@Excel(name = "从事工作", width = 15)
@ApiModelProperty(value = "从事工作")
private String expCsgz;
/**专家名称*/
@Excel(name = "专家名称", width = 15)
@ApiModelProperty(value = "专家名称")
private String name;
/**专业*/
@Excel(name = "专业", width = 15)
@ApiModelProperty(value = "专业")
private String teamajor;
}

@ -0,0 +1,17 @@
package org.jeecg.modules.demo.seteacher.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.seteacher.entity.Seteacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: seteacher
* @Author: jeecg-boot
* @Date: 2024-08-23
* @Version: V1.0
*/
public interface SeteacherMapper extends BaseMapper<Seteacher> {
}

@ -0,0 +1,5 @@
<?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="org.jeecg.modules.demo.seteacher.mapper.SeteacherMapper">
</mapper>

@ -0,0 +1,14 @@
package org.jeecg.modules.demo.seteacher.service;
import org.jeecg.modules.demo.seteacher.entity.Seteacher;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: seteacher
* @Author: jeecg-boot
* @Date: 2024-08-23
* @Version: V1.0
*/
public interface ISeteacherService extends IService<Seteacher> {
}

@ -0,0 +1,19 @@
package org.jeecg.modules.demo.seteacher.service.impl;
import org.jeecg.modules.demo.seteacher.entity.Seteacher;
import org.jeecg.modules.demo.seteacher.mapper.SeteacherMapper;
import org.jeecg.modules.demo.seteacher.service.ISeteacherService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: seteacher
* @Author: jeecg-boot
* @Date: 2024-08-23
* @Version: V1.0
*/
@Service
public class SeteacherServiceImpl extends ServiceImpl<SeteacherMapper, Seteacher> implements ISeteacherService {
}
Loading…
Cancel
Save