2023-03-27 14:11:18 +08:00
|
|
|
package com.rzyc.controller;
|
|
|
|
|
|
2023-03-29 21:00:54 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
2023-03-27 14:11:18 +08:00
|
|
|
import com.common.utils.DateUtils;
|
|
|
|
|
import com.common.utils.StringUtils;
|
|
|
|
|
import com.common.utils.model.Code;
|
|
|
|
|
import com.common.utils.model.SingleResult;
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
2023-03-29 21:00:54 +08:00
|
|
|
import com.rzyc.bean.pojo.dto.AddEducationResourceDto;
|
|
|
|
|
import com.rzyc.bean.pojo.dto.AddEducationStudyDto;
|
|
|
|
|
import com.rzyc.bean.pojo.vo.EducationResourceVo;
|
|
|
|
|
import com.rzyc.bean.pojo.vo.EducationStudyListVo;
|
|
|
|
|
import com.rzyc.bean.pojo.vo.ListPageVo;
|
2023-03-27 14:11:18 +08:00
|
|
|
import com.rzyc.bean.task.dto.PageDto;
|
2023-03-29 21:00:54 +08:00
|
|
|
import com.rzyc.model.EducationResource;
|
2023-03-27 14:11:18 +08:00
|
|
|
import com.rzyc.model.EducationStudy;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2023-03-29 21:00:54 +08:00
|
|
|
import org.springframework.beans.BeanUtils;
|
2023-03-27 14:11:18 +08:00
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2023-03-29 21:00:54 +08:00
|
|
|
|
2023-03-27 14:11:18 +08:00
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import javax.validation.constraints.NotBlank;
|
2023-03-29 21:00:54 +08:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
2023-03-27 14:11:18 +08:00
|
|
|
import java.util.Date;
|
2023-03-29 21:00:54 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
2023-03-27 14:11:18 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @BelongsProject: inventory-api
|
|
|
|
|
* @BelongsPackage: com.rzyc.controller
|
|
|
|
|
* @Author: SYZ
|
|
|
|
|
* @CreateTime: 2023-03-27 10:39
|
|
|
|
|
* @Version: 1.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Api(tags = "教育培训接口")
|
|
|
|
|
@CrossOrigin("*")
|
|
|
|
|
@RequestMapping("education")
|
|
|
|
|
@Controller
|
|
|
|
|
@Validated
|
|
|
|
|
public class EducationStudyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
2023-03-29 21:00:54 +08:00
|
|
|
* @description:获取培训学习列表
|
|
|
|
|
* @author: SYZ
|
|
|
|
|
* @date: 2023/3/29 20:09
|
|
|
|
|
* @param: [dto, year, enterpriseId]
|
|
|
|
|
* @return: com.common.utils.model.SingleResult<com.rzyc.bean.pojo.vo.ListPageVo<com.rzyc.bean.pojo.vo.EducationStudyListVo>>
|
|
|
|
|
**/
|
|
|
|
|
@ApiOperation(value = "获取培训学习列表")
|
2023-03-27 14:11:18 +08:00
|
|
|
@ApiImplicitParams({
|
2023-03-29 21:00:54 +08:00
|
|
|
@ApiImplicitParam(name = "year", value = "年份", dataType = "int", paramType = "query"),
|
|
|
|
|
@ApiImplicitParam(name = "enterpriseId", value = "企业id", dataType = "string", paramType = "query", required = true)
|
2023-03-27 14:11:18 +08:00
|
|
|
})
|
|
|
|
|
@GetMapping("/getList")
|
|
|
|
|
@ResponseBody
|
2023-03-29 21:00:54 +08:00
|
|
|
public SingleResult<ListPageVo<EducationStudyListVo>> getList(@Valid PageDto dto, Integer year, String enterpriseId) throws Exception {
|
|
|
|
|
SingleResult<ListPageVo<EducationStudyListVo>> result = new SingleResult<>();
|
|
|
|
|
String startDate = "";
|
|
|
|
|
String endDate = "";
|
|
|
|
|
if (null != year) {
|
|
|
|
|
startDate = DateUtils.parseDate2String(DateUtils.getFirstDayOfMonth(year, 1), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
endDate = DateUtils.parseDate2String(DateUtils.getLastDayOfMonth(year, 12), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
2023-03-27 14:11:18 +08:00
|
|
|
PageHelper.startPage(dto.getPage(), dto.getPageSize());
|
2023-03-29 21:00:54 +08:00
|
|
|
Page<EducationStudyListVo> list = (Page<EducationStudyListVo>) educationStudyMapper.selectEducationStudyList(startDate, endDate, enterpriseId, dto.getCondition());
|
2023-03-27 14:11:18 +08:00
|
|
|
ListPageVo<EducationStudyListVo> pageVo = new ListPageVo<>();
|
|
|
|
|
pageVo.setRows(list);
|
|
|
|
|
pageVo.setTotal(list.getTotal());
|
|
|
|
|
pageVo.setPage(list.getPageNum());
|
|
|
|
|
pageVo.setPageSize(list.getPageSize());
|
|
|
|
|
result.setData(pageVo);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 21:00:54 +08:00
|
|
|
/**
|
|
|
|
|
* @description:添加培训学习
|
|
|
|
|
* @author: SYZ
|
|
|
|
|
* @date: 2023/3/29 20:09
|
|
|
|
|
* @param: [dto]
|
|
|
|
|
* @return: com.common.utils.model.SingleResult
|
|
|
|
|
**/
|
|
|
|
|
@ApiOperation(value = "添加培训学习")
|
2023-03-27 14:11:18 +08:00
|
|
|
@PostMapping("/addOne")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public SingleResult addOne(@Valid AddEducationStudyDto dto) {
|
|
|
|
|
SingleResult<Object> result = new SingleResult<>();
|
2023-03-29 21:00:54 +08:00
|
|
|
Integer count = educationStudyMapper.selectCount(
|
|
|
|
|
new QueryWrapper<EducationStudy>().select("1").eq("id", dto.getId())
|
|
|
|
|
);
|
2023-03-27 14:11:18 +08:00
|
|
|
EducationStudy educationStudy = new EducationStudy();
|
|
|
|
|
educationStudy.setId(dto.getId());
|
|
|
|
|
educationStudy.setEnterpriseId(dto.getEnterpriseId());
|
|
|
|
|
educationStudy.setTitle(StringUtils.isBlank(dto.getTitle()) ? "" : dto.getTitle());
|
|
|
|
|
educationStudy.setContent(StringUtils.isBlank(dto.getContent()) ? "" : dto.getContent());
|
|
|
|
|
educationStudy.setUserId(StringUtils.isBlank(dto.getUserId()) ? "" : dto.getUserId());
|
2023-03-29 21:00:54 +08:00
|
|
|
educationStudy.setStudyDate(DateUtils.parseString2Date(dto.getStudyDate(), "yyyy-MM-dd"));
|
2023-03-27 14:11:18 +08:00
|
|
|
educationStudy.setStudyUnit(StringUtils.isBlank(dto.getStudyUnit()) ? "" : dto.getStudyUnit());
|
|
|
|
|
educationStudy.setCreateTime(new Date());
|
2023-03-29 21:00:54 +08:00
|
|
|
if (0 == count){
|
|
|
|
|
int insertRow = educationStudyMapper.insert(educationStudy);
|
|
|
|
|
return (0 == insertRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功");
|
|
|
|
|
}else{
|
|
|
|
|
int updateRow = educationStudyMapper.updateById(educationStudy);
|
|
|
|
|
return (0 == updateRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功");
|
|
|
|
|
}
|
2023-03-27 14:11:18 +08:00
|
|
|
}
|
|
|
|
|
|
2023-03-29 21:00:54 +08:00
|
|
|
/**
|
|
|
|
|
* @description:删除培训学习
|
|
|
|
|
* @author: SYZ
|
|
|
|
|
* @date: 2023/3/29 20:09
|
|
|
|
|
* @param: [id]
|
|
|
|
|
* @return: com.common.utils.model.SingleResult
|
|
|
|
|
**/
|
|
|
|
|
@ApiOperation(value = "删除培训学习")
|
2023-03-27 14:11:18 +08:00
|
|
|
@GetMapping("/delOne")
|
|
|
|
|
@ApiImplicitParam(name = "id", value = "主键id", dataType = "string", paramType = "query", required = true)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public SingleResult delOne(@NotBlank(message = "id不能为空") String id) {
|
|
|
|
|
SingleResult<Object> result = new SingleResult<>();
|
|
|
|
|
int delRow = educationStudyMapper.deleteById(id);
|
2023-03-29 21:00:54 +08:00
|
|
|
return (0 == delRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功");
|
2023-03-27 14:11:18 +08:00
|
|
|
}
|
|
|
|
|
|
2023-03-29 21:00:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-27 14:11:18 +08:00
|
|
|
}
|
|
|
|
|
|