Commit 136d263a authored by ‘老张’'s avatar ‘老张’

员工年假

parent 856b7396
package com.ruoyi.controller;
import java.util.Calendar;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.EmployeeAnnualLeave;
import com.ruoyi.service.IEmployeeAnnualLeaveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 员工年假Controller
*
* @author ruoyi
* @date 2025-04-17
*/
@RestController
@RequestMapping("/system/annualleave")
public class EmployeeAnnualLeaveController extends BaseController
{
@Autowired
private IEmployeeAnnualLeaveService employeeAnnualLeaveService;
/**
* 查询员工年假列表
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:list')")
@GetMapping("/list")
public TableDataInfo list(EmployeeAnnualLeave employeeAnnualLeave)
{
startPage();
List<EmployeeAnnualLeave> list = employeeAnnualLeaveService.selectEmployeeAnnualLeaveList(employeeAnnualLeave);
return getDataTable(list);
}
/**
* 导出员工年假列表
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:export')")
@Log(title = "员工年假", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EmployeeAnnualLeave employeeAnnualLeave)
{
List<EmployeeAnnualLeave> list = employeeAnnualLeaveService.selectEmployeeAnnualLeaveList(employeeAnnualLeave);
ExcelUtil<EmployeeAnnualLeave> util = new ExcelUtil<EmployeeAnnualLeave>(EmployeeAnnualLeave.class);
util.exportExcel(response, list, "员工年假数据");
}
/**
* 获取员工年假详细信息
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(employeeAnnualLeaveService.selectEmployeeAnnualLeaveById(id));
}
/**
* 新增员工年假
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:add')")
@Log(title = "员工年假", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EmployeeAnnualLeave employeeAnnualLeave)
{
return toAjax(employeeAnnualLeaveService.insertEmployeeAnnualLeave(employeeAnnualLeave));
}
/**
* 修改员工年假
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:edit')")
@Log(title = "员工年假", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EmployeeAnnualLeave employeeAnnualLeave)
{
return toAjax(employeeAnnualLeaveService.updateEmployeeAnnualLeave(employeeAnnualLeave));
}
/**
* 删除员工年假
*/
@PreAuthorize("@ss.hasPermi('psa:annualleave:remove')")
@Log(title = "员工年假", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(employeeAnnualLeaveService.deleteEmployeeAnnualLeaveByIds(ids));
}
}
package com.ruoyi.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.EmployeeBalance;
import com.ruoyi.service.IEmployeeBalanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 员工余额Controller
*
* @author ruoyi
* @date 2025-04-21
*/
@RestController
@RequestMapping("/system/balance")
public class EmployeeBalanceController extends BaseController
{
@Autowired
private IEmployeeBalanceService employeeBalanceService;
/**
* 查询员工余额列表
*/
@PreAuthorize("@ss.hasPermi('system:balance:list')")
@GetMapping("/list")
public TableDataInfo list(EmployeeBalance employeeBalance)
{
startPage();
List<EmployeeBalance> list = employeeBalanceService.selectEmployeeBalanceList(employeeBalance);
return getDataTable(list);
}
/**
* 导出员工余额列表
*/
@PreAuthorize("@ss.hasPermi('system:balance:export')")
@Log(title = "员工余额", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EmployeeBalance employeeBalance)
{
List<EmployeeBalance> list = employeeBalanceService.selectEmployeeBalanceList(employeeBalance);
ExcelUtil<EmployeeBalance> util = new ExcelUtil<EmployeeBalance>(EmployeeBalance.class);
util.exportExcel(response, list, "员工余额数据");
}
/**
* 获取员工余额详细信息
*/
@PreAuthorize("@ss.hasPermi('system:balance:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(employeeBalanceService.selectEmployeeBalanceById(id));
}
/**
* 新增员工余额
*/
@PreAuthorize("@ss.hasPermi('system:balance:add')")
@Log(title = "员工余额", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EmployeeBalance employeeBalance)
{
return toAjax(employeeBalanceService.insertEmployeeBalance(employeeBalance));
}
/**
* 修改员工余额
*/
@PreAuthorize("@ss.hasPermi('system:balance:edit')")
@Log(title = "员工余额", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EmployeeBalance employeeBalance)
{
return toAjax(employeeBalanceService.updateEmployeeBalance(employeeBalance));
}
/**
* 删除员工余额
*/
@PreAuthorize("@ss.hasPermi('system:balance:remove')")
@Log(title = "员工余额", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(employeeBalanceService.deleteEmployeeBalanceByIds(ids));
}
}
package com.ruoyi.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 员工年假对象 employee_annual_leave
*
* @author ruoyi
* @date 2025-04-17
*/
public class EmployeeAnnualLeave extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 关联用户ID */
private Long userId;
/** 姓名 */
@Excel(name = "姓名")
private String uname;
/** 年份 */
@Excel(name = "年份")
private Long year;
/** 总年假天数 */
@Excel(name = "总年假天数")
private Long totalDays;
/** 已使用年假天数 */
@Excel(name = "已使用年假天数")
private Long usedDays;
/** 剩余年假天数 */
@Excel(name = "剩余年假天数")
private Long remainingDays;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setYear(Long year)
{
this.year = year;
}
public Long getYear()
{
return year;
}
public void setTotalDays(Long totalDays)
{
this.totalDays = totalDays;
}
public Long getTotalDays()
{
return totalDays;
}
public void setUsedDays(Long usedDays)
{
this.usedDays = usedDays;
}
public Long getUsedDays()
{
return usedDays;
}
public void setRemainingDays(Long remainingDays)
{
this.remainingDays = remainingDays;
}
public Long getRemainingDays()
{
return remainingDays;
}
public void setCreatedTime(Date createdTime)
{
this.createdTime = createdTime;
}
public Date getCreatedTime()
{
return createdTime;
}
public void setUpdatedTime(Date updatedTime)
{
this.updatedTime = updatedTime;
}
public Date getUpdatedTime()
{
return updatedTime;
}
public void setUname(String uname)
{
this.uname = uname;
}
public String getUname()
{
return uname;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userId", getUserId())
.append("year", getYear())
.append("totalDays", getTotalDays())
.append("usedDays", getUsedDays())
.append("remainingDays", getRemainingDays())
.append("createdTime", getCreatedTime())
.append("updatedTime", getUpdatedTime())
.append("uname", getUname())
.toString();
}
}
package com.ruoyi.mapper;
import java.util.List;
import com.ruoyi.domain.EmployeeAnnualLeave;
/**
* 员工年假Mapper接口
*
* @author ruoyi
* @date 2025-04-17
*/
public interface EmployeeAnnualLeaveMapper
{
/**
* 查询员工年假
*
* @param id 员工年假主键
* @return 员工年假
*/
public EmployeeAnnualLeave selectEmployeeAnnualLeaveById(Long id);
/**
* 查询员工年假列表
*
* @param employeeAnnualLeave 员工年假
* @return 员工年假集合
*/
public List<EmployeeAnnualLeave> selectEmployeeAnnualLeaveList(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 新增员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
public int insertEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 修改员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
public int updateEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 删除员工年假
*
* @param id 员工年假主键
* @return 结果
*/
public int deleteEmployeeAnnualLeaveById(Long id);
/**
* 批量删除员工年假
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEmployeeAnnualLeaveByIds(Long[] ids);
}
...@@ -4,8 +4,48 @@ import com.ruoyi.domain.EmployeeBalance; ...@@ -4,8 +4,48 @@ import com.ruoyi.domain.EmployeeBalance;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
public interface EmployeeBalanceMapper { public interface EmployeeBalanceMapper {
/**
* 查询员工余额
*
* @param id 员工余额主键
* @return 员工余额
*/
public EmployeeBalance selectEmployeeBalanceById(Long id);
/**
* 查询员工余额列表
*
* @param employeeBalance 员工余额
* @return 员工余额集合
*/
public List<EmployeeBalance> selectEmployeeBalanceList(EmployeeBalance employeeBalance);
/**
* 修改员工余额
*
* @param employeeBalance 员工余额
* @return 结果
*/
public int updateEmployeeBalance(EmployeeBalance employeeBalance);
/**
* 删除员工余额
*
* @param id 员工余额主键
* @return 结果
*/
public int deleteEmployeeBalanceById(Long id);
/**
* 批量删除员工余额
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEmployeeBalanceByIds(Long[] ids);
/** /**
* 检查员工是否已有加班记录 * 检查员工是否已有加班记录
......
package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.EmployeeAnnualLeave;
/**
* 员工年假Service接口
*
* @author ruoyi
* @date 2025-04-17
*/
public interface IEmployeeAnnualLeaveService
{
/**
* 查询员工年假
*
* @param id 员工年假主键
* @return 员工年假
*/
public EmployeeAnnualLeave selectEmployeeAnnualLeaveById(Long id);
/**
* 查询员工年假列表
*
* @param employeeAnnualLeave 员工年假
* @return 员工年假集合
*/
public List<EmployeeAnnualLeave> selectEmployeeAnnualLeaveList(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 新增员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
public int insertEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 修改员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
public int updateEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave);
/**
* 批量删除员工年假
*
* @param ids 需要删除的员工年假主键集合
* @return 结果
*/
public int deleteEmployeeAnnualLeaveByIds(Long[] ids);
/**
* 删除员工年假信息
*
* @param id 员工年假主键
* @return 结果
*/
public int deleteEmployeeAnnualLeaveById(Long id);
}
package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.EmployeeBalance;
/**
* 员工余额Service接口
*
* @author ruoyi
* @date 2025-04-21
*/
public interface IEmployeeBalanceService
{
/**
* 查询员工余额
*
* @param id 员工余额主键
* @return 员工余额
*/
public EmployeeBalance selectEmployeeBalanceById(Long id);
/**
* 查询员工余额列表
*
* @param employeeBalance 员工余额
* @return 员工余额集合
*/
public List<EmployeeBalance> selectEmployeeBalanceList(EmployeeBalance employeeBalance);
/**
* 新增员工余额
*
* @param employeeBalance 员工余额
* @return 结果
*/
public int insertEmployeeBalance(EmployeeBalance employeeBalance);
/**
* 修改员工余额
*
* @param employeeBalance 员工余额
* @return 结果
*/
public int updateEmployeeBalance(EmployeeBalance employeeBalance);
/**
* 批量删除员工余额
*
* @param ids 需要删除的员工余额主键集合
* @return 结果
*/
public int deleteEmployeeBalanceByIds(Long[] ids);
/**
* 删除员工余额信息
*
* @param id 员工余额主键
* @return 结果
*/
public int deleteEmployeeBalanceById(Long id);
}
package com.ruoyi.service.impl;
import java.util.Calendar;
import java.util.List;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.EmployeeAnnualLeaveMapper;
import com.ruoyi.domain.EmployeeAnnualLeave;
import com.ruoyi.service.IEmployeeAnnualLeaveService;
/**
* 员工年假Service业务层处理
*
* @author ruoyi
* @date 2025-04-17
*/
@Service
public class EmployeeAnnualLeaveServiceImpl implements IEmployeeAnnualLeaveService
{
@Autowired
private EmployeeAnnualLeaveMapper employeeAnnualLeaveMapper;
@Autowired
private ISysUserService ISysUserService;
/**
* 查询员工年假
*
* @param id 员工年假主键
* @return 员工年假
*/
@Override
public EmployeeAnnualLeave selectEmployeeAnnualLeaveById(Long id)
{
return employeeAnnualLeaveMapper.selectEmployeeAnnualLeaveById(id);
}
/**
* 查询员工年假列表
*
* @param employeeAnnualLeave 员工年假
* @return 员工年假
*/
@Override
public List<EmployeeAnnualLeave> selectEmployeeAnnualLeaveList(EmployeeAnnualLeave employeeAnnualLeave)
{
return employeeAnnualLeaveMapper.selectEmployeeAnnualLeaveList(employeeAnnualLeave);
}
/**
* 新增员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
@Override
public int insertEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave)
{
// 设置默认年份为当前年份
if (employeeAnnualLeave.getYear() == null) {
Calendar calendar = Calendar.getInstance();
employeeAnnualLeave.setYear((long) calendar.get(Calendar.YEAR));
}
// 设置默认年假天数为10天
if (employeeAnnualLeave.getTotalDays() == null) {
employeeAnnualLeave.setTotalDays(10L);
}
Object user = ISysUserService.selectUserByUserName(employeeAnnualLeave.getUname());
if (user == null) {
return -2; // 未找到对应员工
}
Long userId = ISysUserService.selectUserByUserName(employeeAnnualLeave.getUname()).getUserId();
employeeAnnualLeave.setUserId(userId);
// 验证已使用天数不能超过总天数
if (employeeAnnualLeave.getUsedDays() > employeeAnnualLeave.getTotalDays()) {
return -1; // 返回-1表示已使用天数超过总天数
}
// 自动计算剩余天数
employeeAnnualLeave.setRemainingDays(employeeAnnualLeave.getTotalDays() - employeeAnnualLeave.getUsedDays());
return employeeAnnualLeaveMapper.insertEmployeeAnnualLeave(employeeAnnualLeave);
}
/**
* 修改员工年假
*
* @param employeeAnnualLeave 员工年假
* @return 结果
*/
@Override
public int updateEmployeeAnnualLeave(EmployeeAnnualLeave employeeAnnualLeave)
{
// 设置默认年份为当前年份
if (employeeAnnualLeave.getYear() == null) {
Calendar calendar = Calendar.getInstance();
employeeAnnualLeave.setYear((long) calendar.get(Calendar.YEAR));
}
// 设置默认年假天数为10天
if (employeeAnnualLeave.getTotalDays() == null) {
employeeAnnualLeave.setTotalDays(10L);
}
Object user = ISysUserService.selectUserByUserName(employeeAnnualLeave.getUname());
if (user == null) {
return -2; // 未找到对应员工
}
Long userId = ISysUserService.selectUserByUserName(employeeAnnualLeave.getUname()).getUserId();
employeeAnnualLeave.setUserId(userId);
// 验证已使用天数不能超过总天数
if (employeeAnnualLeave.getUsedDays() > employeeAnnualLeave.getTotalDays()) {
return -1; // 返回-1表示已使用天数超过总天数
}
// 自动计算剩余天数
employeeAnnualLeave.setRemainingDays(employeeAnnualLeave.getTotalDays() - employeeAnnualLeave.getUsedDays());
return employeeAnnualLeaveMapper.updateEmployeeAnnualLeave(employeeAnnualLeave);
}
/**
* 批量删除员工年假
*
* @param ids 需要删除的员工年假主键
* @return 结果
*/
@Override
public int deleteEmployeeAnnualLeaveByIds(Long[] ids)
{
return employeeAnnualLeaveMapper.deleteEmployeeAnnualLeaveByIds(ids);
}
/**
* 删除员工年假信息
*
* @param id 员工年假主键
* @return 结果
*/
@Override
public int deleteEmployeeAnnualLeaveById(Long id)
{
return employeeAnnualLeaveMapper.deleteEmployeeAnnualLeaveById(id);
}
}
package com.ruoyi.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.EmployeeBalanceMapper;
import com.ruoyi.domain.EmployeeBalance;
import com.ruoyi.service.IEmployeeBalanceService;
/**
* 员工余额Service业务层处理
*
* @author ruoyi
* @date 2025-04-21
*/
@Service
public class EmployeeBalanceServiceImpl implements IEmployeeBalanceService
{
@Autowired
private EmployeeBalanceMapper employeeBalanceMapper;
/**
* 查询员工余额
*
* @param id 员工余额主键
* @return 员工余额
*/
@Override
public EmployeeBalance selectEmployeeBalanceById(Long id)
{
return employeeBalanceMapper.selectEmployeeBalanceById(id);
}
/**
* 查询员工余额列表
*
* @param employeeBalance 员工余额
* @return 员工余额
*/
@Override
public List<EmployeeBalance> selectEmployeeBalanceList(EmployeeBalance employeeBalance)
{
return employeeBalanceMapper.selectEmployeeBalanceList(employeeBalance);
}
/**
* 新增员工余额
*
* @param employeeBalance 员工余额
* @return 结果
*/
@Override
public int insertEmployeeBalance(EmployeeBalance employeeBalance)
{
return employeeBalanceMapper.insertEmployeeBalance(employeeBalance);
}
/**
* 修改员工余额
*
* @param employeeBalance 员工余额
* @return 结果
*/
@Override
public int updateEmployeeBalance(EmployeeBalance employeeBalance)
{
return employeeBalanceMapper.updateEmployeeBalance(employeeBalance);
}
/**
* 批量删除员工余额
*
* @param ids 需要删除的员工余额主键
* @return 结果
*/
@Override
public int deleteEmployeeBalanceByIds(Long[] ids)
{
return employeeBalanceMapper.deleteEmployeeBalanceByIds(ids);
}
/**
* 删除员工余额信息
*
* @param id 员工余额主键
* @return 结果
*/
@Override
public int deleteEmployeeBalanceById(Long id)
{
return employeeBalanceMapper.deleteEmployeeBalanceById(id);
}
}
<?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="com.ruoyi.mapper.EmployeeAnnualLeaveMapper">
<resultMap type="EmployeeAnnualLeave" id="EmployeeAnnualLeaveResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="uname" column="uname" />
<result property="year" column="year" />
<result property="totalDays" column="total_days" />
<result property="usedDays" column="used_days" />
<result property="remainingDays" column="remaining_days" />
<result property="createdTime" column="created_time" />
<result property="updatedTime" column="updated_time" />
</resultMap>
<sql id="selectEmployeeAnnualLeaveVo">
select id, user_id, uname,year, total_days, used_days, remaining_days, created_time, updated_time from employee_annual_leave
</sql>
<select id="selectEmployeeAnnualLeaveList" parameterType="EmployeeAnnualLeave" resultMap="EmployeeAnnualLeaveResult">
<include refid="selectEmployeeAnnualLeaveVo"/>
<where>
<if test="userId != null"> and user_id = #{userId}</if>
<if test="uname != null and uname != ''"> and uname like concat('%', #{uname}, '%')</if>
<if test="year != null "> and year = #{year}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
</where>
</select>
<select id="selectEmployeeAnnualLeaveById" parameterType="Long" resultMap="EmployeeAnnualLeaveResult">
<include refid="selectEmployeeAnnualLeaveVo"/>
where id = #{id}
</select>
<insert id="insertEmployeeAnnualLeave" parameterType="EmployeeAnnualLeave" useGeneratedKeys="true" keyProperty="id">
insert into employee_annual_leave
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="uname != null">uname,</if>
<if test="year != null">year,</if>
<if test="totalDays != null">total_days,</if>
<if test="usedDays != null">used_days,</if>
<if test="remainingDays != null">remaining_days,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="uname != null">#{uname},</if>
<if test="year != null">#{year},</if>
<if test="totalDays != null">#{totalDays},</if>
<if test="usedDays != null">#{usedDays},</if>
<if test="remainingDays != null">#{remainingDays},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedTime != null">#{updatedTime},</if>
</trim>
</insert>
<update id="updateEmployeeAnnualLeave" parameterType="EmployeeAnnualLeave">
update employee_annual_leave
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="uname != null">uname = #{uname},</if>
<if test="year != null">year = #{year},</if>
<if test="totalDays != null">total_days = #{totalDays},</if>
<if test="usedDays != null">used_days = #{usedDays},</if>
<if test="remainingDays != null">remaining_days = #{remainingDays},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmployeeAnnualLeaveById" parameterType="Long">
delete from employee_annual_leave where id = #{id}
</delete>
<delete id="deleteEmployeeAnnualLeaveByIds" parameterType="String">
delete from employee_annual_leave where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
...@@ -3,6 +3,75 @@ ...@@ -3,6 +3,75 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mapper.EmployeeBalanceMapper"> <mapper namespace="com.ruoyi.mapper.EmployeeBalanceMapper">
<resultMap type="EmployeeBalance" id="EmployeeBalanceResult">
<result property="id" column="id" />
<result property="employeeId" column="employee_id" />
<result property="annualLeaveBalance" column="annual_leave_balance" />
<result property="overtimeHoursBalance" column="overtime_hours_balance" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
</resultMap>
<sql id="selectEmployeeBalanceVo">
select id, employee_id, annual_leave_balance, overtime_hours_balance, created_at, updated_at from employee_balance
</sql>
<select id="selectEmployeeBalanceList" parameterType="EmployeeBalance" resultMap="EmployeeBalanceResult">
<include refid="selectEmployeeBalanceVo"/>
<where>
<if test="employeeId != null "> and employee_id = #{employeeId}</if>
<if test="annualLeaveBalance != null "> and annual_leave_balance = #{annualLeaveBalance}</if>
<if test="overtimeHoursBalance != null "> and overtime_hours_balance = #{overtimeHoursBalance}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where>
</select>
<select id="selectEmployeeBalanceById" parameterType="Long" resultMap="EmployeeBalanceResult">
<include refid="selectEmployeeBalanceVo"/>
where id = #{id}
</select>
<insert id="insertEmployeeBalance" parameterType="EmployeeBalance" useGeneratedKeys="true" keyProperty="id">
insert into employee_balance
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="employeeId != null">employee_id,</if>
<if test="annualLeaveBalance != null">annual_leave_balance,</if>
<if test="overtimeHoursBalance != null">overtime_hours_balance,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="employeeId != null">#{employeeId},</if>
<if test="annualLeaveBalance != null">#{annualLeaveBalance},</if>
<if test="overtimeHoursBalance != null">#{overtimeHoursBalance},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
</trim>
</insert>
<!--todo 方法名重复-->
<update id="updateEmployeeBalance" parameterType="EmployeeBalance">
update employee_balance
<trim prefix="SET" suffixOverrides=",">
<if test="employeeId != null">employee_id = #{employeeId},</if>
<if test="annualLeaveBalance != null">annual_leave_balance = #{annualLeaveBalance},</if>
<if test="overtimeHoursBalance != null">overtime_hours_balance = #{overtimeHoursBalance},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmployeeBalanceById" parameterType="Long">
delete from employee_balance where id = #{id}
</delete>
<delete id="deleteEmployeeBalanceByIds" parameterType="String">
delete from employee_balance where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectEmployeeBalanceByEmployeeId" resultType="com.ruoyi.domain.EmployeeBalance"> <select id="selectEmployeeBalanceByEmployeeId" resultType="com.ruoyi.domain.EmployeeBalance">
SELECT id, employee_id, annual_leave_balance, overtime_hours_balance, created_at, updated_at SELECT id, employee_id, annual_leave_balance, overtime_hours_balance, created_at, updated_at
...@@ -10,7 +79,7 @@ ...@@ -10,7 +79,7 @@
WHERE employee_id = #{employeeId} WHERE employee_id = #{employeeId}
</select> </select>
<insert id="insertEmployeeBalance"> <!-- <insert id="insertEmployeeBalance">
INSERT INTO employee_balance (employee_id, overtime_hours_balance) INSERT INTO employee_balance (employee_id, overtime_hours_balance)
VALUES (#{employeeId}, #{overtimeHoursBalance}) VALUES (#{employeeId}, #{overtimeHoursBalance})
</insert> </insert>
...@@ -20,5 +89,6 @@ ...@@ -20,5 +89,6 @@
SET overtime_hours_balance = overtime_hours_balance + #{overtimeHoursBalance} SET overtime_hours_balance = overtime_hours_balance + #{overtimeHoursBalance}
WHERE employee_id = #{employeeId} WHERE employee_id = #{employeeId}
</update> </update>
-->
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment