parent
a5b2b39ebe
commit
3712e33b19
@ -1,95 +1,129 @@
|
|||||||
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting;
|
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import javax.annotation.Resource;
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import com.chanko.yunxi.mes.module.biz.service.salaryuser.SalaryUserService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import javax.annotation.Resource;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import javax.validation.constraints.*;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import javax.validation.*;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import javax.servlet.http.*;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import java.util.*;
|
|
||||||
import java.io.IOException;
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
import java.util.*;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
import java.io.IOException;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
|
||||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
|
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||||
|
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
|
||||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||||
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
import com.chanko.yunxi.mes.module.biz.service.salarysetting.SalarySettingService;
|
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
||||||
@Tag(name = "管理后台 - 员工工资设置")
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
||||||
@RestController
|
import com.chanko.yunxi.mes.module.biz.service.salarysetting.SalarySettingService;
|
||||||
@RequestMapping("/biz/salary-setting")
|
|
||||||
@Validated
|
@Tag(name = "管理后台 - 员工工资设置")
|
||||||
public class SalarySettingController {
|
@RestController
|
||||||
|
@RequestMapping("/biz/salary-setting")
|
||||||
@Resource
|
@Validated
|
||||||
private SalarySettingService salarySettingService;
|
public class SalarySettingController {
|
||||||
|
|
||||||
@PostMapping("/create")
|
@Resource
|
||||||
@Operation(summary = "创建员工工资设置")
|
private SalaryUserService salaryUserService;
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:create')")
|
|
||||||
public CommonResult<Long> createSalarySetting(@Valid @RequestBody SalarySettingSaveReqVO createReqVO) {
|
@Resource
|
||||||
return success(salarySettingService.createSalarySetting(createReqVO));
|
private SalarySettingService salarySettingService;
|
||||||
}
|
|
||||||
|
@PostMapping("/create")
|
||||||
@PutMapping("/update")
|
@Operation(summary = "创建员工工资设置主")
|
||||||
@Operation(summary = "更新员工工资设置")
|
@PreAuthorize("@ss.hasPermission('biz:salary-user:create')")
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:update')")
|
public CommonResult<Long> createSalaryUser(@Valid @RequestBody SalaryUserSaveReqVO createReqVO) {
|
||||||
public CommonResult<Boolean> updateSalarySetting(@Valid @RequestBody SalarySettingSaveReqVO updateReqVO) {
|
return success(salaryUserService.createSalaryUser(createReqVO));
|
||||||
salarySettingService.updateSalarySetting(updateReqVO);
|
}
|
||||||
return success(true);
|
|
||||||
}
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新员工工资设置主")
|
||||||
@DeleteMapping("/delete")
|
@PreAuthorize("@ss.hasPermission('biz:salary-user:update')")
|
||||||
@Operation(summary = "删除员工工资设置")
|
public CommonResult<Boolean> updateSalaryUser(@Valid @RequestBody SalaryUserSaveReqVO updateReqVO) {
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
salaryUserService.updateSalaryUser(updateReqVO);
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:delete')")
|
return success(true);
|
||||||
public CommonResult<Boolean> deleteSalarySetting(@RequestParam("id") Long id) {
|
}
|
||||||
salarySettingService.deleteSalarySetting(id);
|
|
||||||
return success(true);
|
@DeleteMapping("/delete")
|
||||||
}
|
@Operation(summary = "删除员工工资设置主")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@GetMapping("/get")
|
@PreAuthorize("@ss.hasPermission('biz:salary-user:delete')")
|
||||||
@Operation(summary = "获得员工工资设置")
|
public CommonResult<Boolean> deleteSalaryUser(@RequestParam("id") Long id) {
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
salaryUserService.deleteSalaryUser(id);
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
|
return success(true);
|
||||||
public CommonResult<SalarySettingRespVO> getSalarySetting(@RequestParam("id") Long id) {
|
}
|
||||||
SalarySettingDO salarySetting = salarySettingService.getSalarySetting(id);
|
@GetMapping("/get")
|
||||||
return success(BeanUtils.toBean(salarySetting, SalarySettingRespVO.class));
|
@Operation(summary = "获得员工工资设置")
|
||||||
}
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
|
||||||
@GetMapping("/page")
|
public CommonResult<SalaryUserRespVO> getSalarySetting(@RequestParam("id") Long id) {
|
||||||
@Operation(summary = "获得员工工资设置分页")
|
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
|
SalaryUserDO salaryUserDO = salaryUserService.getSalaryUser(id);
|
||||||
public CommonResult<PageResult<SalarySettingRespVO>> getSalarySettingPage(@Valid SalarySettingPageReqVO pageReqVO) {
|
|
||||||
PageResult<SalarySettingDO> pageResult = salarySettingService.getSalarySettingPage(pageReqVO);
|
SalarySettingPageReqVO pageReqVO = new SalarySettingPageReqVO();
|
||||||
return success(BeanUtils.toBean(pageResult, SalarySettingRespVO.class));
|
pageReqVO.setUserId(salaryUserDO.getUserId());
|
||||||
}
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
PageResult<SalarySettingDO> salarySetting = salarySettingService.getSalarySettingByUserIdPage(pageReqVO);
|
||||||
@GetMapping("/export-excel")
|
SalaryUserRespVO result = BeanUtils.toBean(salaryUserDO, SalaryUserRespVO.class);
|
||||||
@Operation(summary = "导出员工工资设置 Excel")
|
result.setSetting(salarySetting.getList());
|
||||||
@PreAuthorize("@ss.hasPermission('biz:salary-setting:export')")
|
return success(result);
|
||||||
@OperateLog(type = EXPORT)
|
}
|
||||||
public void exportSalarySettingExcel(@Valid SalarySettingPageReqVO pageReqVO,
|
|
||||||
HttpServletResponse response) throws IOException {
|
@GetMapping("/page-setting")
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
@Operation(summary = "获得员工工资设置分页")
|
||||||
List<SalarySettingDO> list = salarySettingService.getSalarySettingPage(pageReqVO).getList();
|
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
|
||||||
// 导出 Excel
|
public CommonResult<PageResult<SalarySettingRespVO>> getSalarySettingPage(@Valid SalarySettingPageReqVO pageReqVO) {
|
||||||
ExcelUtils.write(response, "员工工资设置.xls", "数据", SalarySettingRespVO.class,
|
PageResult<SalarySettingDO> pageResult = salarySettingService.getSalarySettingPage(pageReqVO);
|
||||||
BeanUtils.toBean(list, SalarySettingRespVO.class));
|
return success(BeanUtils.toBean(pageResult, SalarySettingRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@GetMapping("/export-setting-excel")
|
||||||
|
@Operation(summary = "导出员工工资设置 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('biz:salary-setting:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportSalarySettingExcel(@Valid SalarySettingPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<SalarySettingDO> list = salarySettingService.getSalarySettingPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "员工工资设置.xls", "数据", SalarySettingRespVO.class,
|
||||||
|
BeanUtils.toBean(list, SalarySettingRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得员工工资设置主分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('biz:salary-user:query')")
|
||||||
|
public CommonResult<PageResult<SalaryUserRespVO>> getSalaryUserPage(@Valid SalaryUserPageReqVO pageReqVO) {
|
||||||
|
PageResult<SalaryUserDO> pageResult = salaryUserService.getSalaryUserPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, SalaryUserRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出员工工资设置主表 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('biz:salary-user:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportSalaryUserExcel(@Valid SalaryUserPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<SalaryUserDO> list = salaryUserService.getSalaryUserPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "员工工资设置主表.xls", "数据", SalaryUserRespVO.class,
|
||||||
|
BeanUtils.toBean(list, SalaryUserRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.chanko.yunxi.mes.module.biz.dal.mysql.salaryuser;
|
||||||
|
|
||||||
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
|
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalarySettingPageReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
|
||||||
|
import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工工资设置主 Mapper
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SalaryUserMapper extends BaseMapperX<SalaryUserDO> {
|
||||||
|
|
||||||
|
// default PageResult<SalaryUserDO> selectPage(SalaryUserPageReqVO reqVO) {
|
||||||
|
// return selectPage(reqVO, new LambdaQueryWrapperX<SalaryUserDO>()
|
||||||
|
// .eqIfPresent(SalaryUserDO::getId, reqVO.getId())
|
||||||
|
// .eqIfPresent(SalaryUserDO::getUserId, reqVO.getUserId())
|
||||||
|
// .eqIfPresent(SalaryUserDO::getSalaryType, reqVO.getSalaryType())
|
||||||
|
// .eqIfPresent(SalaryUserDO::getPrice, reqVO.getPrice())
|
||||||
|
// .eqIfPresent(SalaryUserDO::getProcedure, reqVO.getProcedure())
|
||||||
|
// .eqIfPresent(SalaryUserDO::getStatus, reqVO.getStatus())
|
||||||
|
// .betweenIfPresent(SalaryUserDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
// .orderByDesc(SalaryUserDO::getId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
default PageResult<SalaryUserDO> selectPage(SalaryUserPageReqVO reqVO) {
|
||||||
|
MPJLambdaWrapper<SalaryUserDO> query = new MPJLambdaWrapper<>();
|
||||||
|
query.selectAll(SalaryUserDO.class)
|
||||||
|
.select("u.nickname as userName", "u.username as userCode")
|
||||||
|
.leftJoin(AdminUserDO.class, "u", AdminUserDO::getId, SalaryUserDO::getUserId)
|
||||||
|
.disableSubLogicDel()
|
||||||
|
.orderByDesc(SalaryUserDO::getUserId);
|
||||||
|
query.like(!StringUtils.isEmpty(reqVO.getUserCode()), "u.username", reqVO.getUserCode())
|
||||||
|
.like(!StringUtils.isEmpty(reqVO.getUserName()), "u.nickname", reqVO.getUserName())
|
||||||
|
.eq(!StringUtils.isEmpty(reqVO.getUserId()), SalaryUserDO::getUserId, reqVO.getUserId())
|
||||||
|
;
|
||||||
|
return selectPage(reqVO, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,55 +1,63 @@
|
|||||||
package com.chanko.yunxi.mes.module.biz.service.salarysetting;
|
package com.chanko.yunxi.mes.module.biz.service.salarysetting;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
||||||
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工工资设置 Service 接口
|
* 员工工资设置 Service 接口
|
||||||
*
|
*
|
||||||
* @author 管理员
|
* @author 管理员
|
||||||
*/
|
*/
|
||||||
public interface SalarySettingService {
|
public interface SalarySettingService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建员工工资设置
|
* 创建员工工资设置
|
||||||
*
|
*
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createSalarySetting(@Valid SalarySettingSaveReqVO createReqVO);
|
Long createSalarySetting(@Valid SalarySettingSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新员工工资设置
|
* 更新员工工资设置
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateSalarySetting(@Valid SalarySettingSaveReqVO updateReqVO);
|
void updateSalarySetting(@Valid SalarySettingSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除员工工资设置
|
* 删除员工工资设置
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
*/
|
*/
|
||||||
void deleteSalarySetting(Long id);
|
void deleteSalarySetting(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得员工工资设置
|
* 获得员工工资设置
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 员工工资设置
|
* @return 员工工资设置
|
||||||
*/
|
*/
|
||||||
SalarySettingDO getSalarySetting(Long id);
|
SalarySettingDO getSalarySetting(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得员工工资设置分页
|
* 获得员工工资设置分页
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 员工工资设置分页
|
* @return 员工工资设置分页
|
||||||
*/
|
*/
|
||||||
PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO);
|
PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 获得员工工资设置分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 员工工资设置分页
|
||||||
|
*/
|
||||||
|
PageResult<SalarySettingDO> getSalarySettingByUserIdPage(SalarySettingPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,74 +1,79 @@
|
|||||||
package com.chanko.yunxi.mes.module.biz.service.salarysetting;
|
package com.chanko.yunxi.mes.module.biz.service.salarysetting;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
|
||||||
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper;
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper;
|
||||||
|
|
||||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
|
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工工资设置 Service 实现类
|
* 员工工资设置 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 管理员
|
* @author 管理员
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class SalarySettingServiceImpl implements SalarySettingService {
|
public class SalarySettingServiceImpl implements SalarySettingService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SalarySettingMapper salarySettingMapper;
|
private SalarySettingMapper salarySettingMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createSalarySetting(SalarySettingSaveReqVO createReqVO) {
|
public Long createSalarySetting(SalarySettingSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
SalarySettingDO salarySetting = BeanUtils.toBean(createReqVO, SalarySettingDO.class);
|
SalarySettingDO salarySetting = BeanUtils.toBean(createReqVO, SalarySettingDO.class);
|
||||||
salarySettingMapper.insert(salarySetting);
|
salarySettingMapper.insert(salarySetting);
|
||||||
// 返回
|
// 返回
|
||||||
return salarySetting.getId();
|
return salarySetting.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSalarySetting(SalarySettingSaveReqVO updateReqVO) {
|
public void updateSalarySetting(SalarySettingSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateSalarySettingExists(updateReqVO.getId());
|
validateSalarySettingExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
SalarySettingDO updateObj = BeanUtils.toBean(updateReqVO, SalarySettingDO.class);
|
SalarySettingDO updateObj = BeanUtils.toBean(updateReqVO, SalarySettingDO.class);
|
||||||
salarySettingMapper.updateById(updateObj);
|
salarySettingMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSalarySetting(Long id) {
|
public void deleteSalarySetting(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateSalarySettingExists(id);
|
validateSalarySettingExists(id);
|
||||||
// 删除
|
// 删除
|
||||||
salarySettingMapper.deleteById(id);
|
salarySettingMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateSalarySettingExists(Long id) {
|
private void validateSalarySettingExists(Long id) {
|
||||||
if (salarySettingMapper.selectById(id) == null) {
|
if (salarySettingMapper.selectById(id) == null) {
|
||||||
throw exception(SALARY_SETTING_NOT_EXISTS);
|
throw exception(SALARY_SETTING_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SalarySettingDO getSalarySetting(Long id) {
|
public SalarySettingDO getSalarySetting(Long id) {
|
||||||
return salarySettingMapper.selectById(id);
|
return salarySettingMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO) {
|
public PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO) {
|
||||||
return salarySettingMapper.selectPage(pageReqVO);
|
return salarySettingMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public PageResult<SalarySettingDO> getSalarySettingByUserIdPage(SalarySettingPageReqVO pageReqVO) {
|
||||||
|
return salarySettingMapper.selectByUserIdPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.chanko.yunxi.mes.module.biz.service.salaryuser;
|
||||||
|
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
|
||||||
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工工资设置主 Service 接口
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
public interface SalaryUserService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建员工工资设置主
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createSalaryUser(@Valid SalaryUserSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新员工工资设置主
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateSalaryUser(@Valid SalaryUserSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除员工工资设置主
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteSalaryUser(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得员工工资设置主
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 员工工资设置主
|
||||||
|
*/
|
||||||
|
SalaryUserDO getSalaryUser(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得员工工资设置主分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 员工工资设置主分页
|
||||||
|
*/
|
||||||
|
PageResult<SalaryUserDO> getSalaryUserPage(SalaryUserPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
package com.chanko.yunxi.mes.module.biz.service.salaryuser;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.warehouse.WarehouseDO;
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
|
||||||
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
|
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.salaryuser.SalaryUserMapper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工工资设置主 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class SalaryUserServiceImpl implements SalaryUserService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SalaryUserMapper salaryUserMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SalarySettingMapper salarySettingMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createSalaryUser(SalaryUserSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
SalaryUserDO salaryUser = BeanUtils.toBean(createReqVO, SalaryUserDO.class);
|
||||||
|
salaryUserMapper.insert(salaryUser);
|
||||||
|
// 返回
|
||||||
|
return salaryUser.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSalaryUser(SalaryUserSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateSalaryUserExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
SalaryUserDO updateObj = BeanUtils.toBean(updateReqVO, SalaryUserDO.class);
|
||||||
|
salaryUserMapper.updateById(updateObj);
|
||||||
|
|
||||||
|
if(CollUtil.isNotEmpty(updateReqVO.getSetting())){
|
||||||
|
List<SalarySettingDO> insertList = new ArrayList<>(16);
|
||||||
|
List<SalarySettingDO> updateList = new ArrayList<>(16);
|
||||||
|
|
||||||
|
updateReqVO.getSetting().forEach(setting ->{
|
||||||
|
SalarySettingDO salarySettingDO =new SalarySettingDO();
|
||||||
|
if(setting.getId()==null || setting.getId()==0){
|
||||||
|
|
||||||
|
salarySettingDO.setSalaryUserId(updateObj.getId());
|
||||||
|
salarySettingDO.setUserId(updateObj.getUserId());
|
||||||
|
salarySettingDO.setSalaryType(updateObj.getSalaryType());
|
||||||
|
salarySettingDO.setSalaryUserId(updateObj.getId());
|
||||||
|
salarySettingDO.setPrice(updateObj.getPrice());
|
||||||
|
salarySettingDO.setStatus(updateObj.getStatus());
|
||||||
|
insertList.add(salarySettingDO);
|
||||||
|
}else{
|
||||||
|
salarySettingDO.setId(setting.getId());
|
||||||
|
salarySettingDO.setSalaryUserId(updateObj.getId());
|
||||||
|
salarySettingDO.setUserId(updateObj.getUserId());
|
||||||
|
salarySettingDO.setSalaryType(updateObj.getSalaryType());
|
||||||
|
salarySettingDO.setSalaryUserId(updateObj.getId());
|
||||||
|
salarySettingDO.setPrice(updateObj.getPrice());
|
||||||
|
salarySettingDO.setStatus(updateObj.getStatus());
|
||||||
|
updateList.add(salarySettingDO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(CollUtil.isNotEmpty(insertList)) salarySettingMapper.insertBatch(insertList);
|
||||||
|
if(CollUtil.isNotEmpty(updateList)) salarySettingMapper.updateBatch(updateList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteSalaryUser(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateSalaryUserExists(id);
|
||||||
|
// 删除
|
||||||
|
salaryUserMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateSalaryUserExists(Long id) {
|
||||||
|
if (salaryUserMapper.selectById(id) == null) {
|
||||||
|
throw exception(SALARY_USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SalaryUserDO getSalaryUser(Long id) {
|
||||||
|
return salaryUserMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<SalaryUserDO> getSalaryUserPage(SalaryUserPageReqVO pageReqVO) {
|
||||||
|
return salaryUserMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue