123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package com.ruoyi.tool.service.impl;
- import java.util.List;
- import com.ruoyi.common.core.domain.entity.SysUser;
- import com.ruoyi.common.exception.ServiceException;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.common.utils.SecurityUtils;
- import com.ruoyi.common.utils.StringUtils;
- import com.ruoyi.common.utils.bean.BeanValidators;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ruoyi.tool.mapper.TPostMapper;
- import com.ruoyi.tool.domain.TPost;
- import com.ruoyi.tool.service.ITPostService;
- /**
- * 职位信息Service业务层处理
- *
- * @author ruoyi
- * @date 2024-06-13
- */
- @Service
- @Slf4j
- public class TPostServiceImpl implements ITPostService {
- @Autowired
- private TPostMapper tPostMapper;
- /**
- * 查询职位信息
- *
- * @param postId 职位信息主键
- * @return 职位信息
- */
- @Override
- public TPost selectTPostByPostId(Long postId) {
- return tPostMapper.selectTPostByPostId(postId);
- }
- /**
- * 查询职位信息列表
- *
- * @param tPost 职位信息
- * @return 职位信息
- */
- @Override
- public List<TPost> selectTPostList(TPost tPost) {
- return tPostMapper.selectTPostList(tPost);
- }
- /**
- * 新增职位信息
- *
- * @param tPost 职位信息
- * @return 结果
- */
- @Override
- public int insertTPost(TPost tPost) {
- tPost.setCreateTime(DateUtils.getNowDate());
- return tPostMapper.insertTPost(tPost);
- }
- /**
- * 修改职位信息
- *
- * @param tPost 职位信息
- * @return 结果
- */
- @Override
- public int updateTPost(TPost tPost) {
- tPost.setUpdateTime(DateUtils.getNowDate());
- return tPostMapper.updateTPost(tPost);
- }
- /**
- * 批量删除职位信息
- *
- * @param postIds 需要删除的职位信息主键
- * @return 结果
- */
- @Override
- public int deleteTPostByPostIds(Long[] postIds) {
- return tPostMapper.deleteTPostByPostIds(postIds);
- }
- /**
- * 删除职位信息信息
- *
- * @param postId 职位信息主键
- * @return 结果
- */
- @Override
- public int deleteTPostByPostId(Long postId) {
- return tPostMapper.deleteTPostByPostId(postId);
- }
- @Override
- public String importPost(List<TPost> postList, String operName) {
- if (StringUtils.isNull(postList) || postList.size() == 0) {
- throw new ServiceException("导入职位数据数据不能为空!");
- }
- int successNum = 0;
- int failureNum = 0;
- StringBuilder successMsg = new StringBuilder();
- StringBuilder failureMsg = new StringBuilder();
- for (TPost post : postList) {
- try {
- tPostMapper.insertTPost(post);
- successMsg.append("<br/>" + successNum + "、职位 " + post.getPostName() + " 导入成功");
- } catch (Exception e) {
- failureNum++;
- String msg = "<br/>" + failureNum + "、职位 " + post.getPostName() + " 导入失败:";
- failureMsg.append(msg + e.getMessage());
- log.error(msg, e);
- }
- }
- if (failureNum > 0) {
- failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
- throw new ServiceException(failureMsg.toString());
- } else {
- successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
- }
- return successMsg.toString();
- }
- }
|