【update】职级等级部分接口功能合并
This commit is contained in:
parent
735241eae1
commit
66c53b2faa
|
@ -1,7 +1,11 @@
|
|||
package com.chint.application.dtos;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author:nxj
|
||||
|
@ -9,9 +13,13 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class RanksDto {
|
||||
private Integer rankId;
|
||||
@NotNull
|
||||
private String rankName;
|
||||
@NotNull
|
||||
private String industry;
|
||||
@NotNull
|
||||
private String companyCode;
|
||||
@NotNull
|
||||
private String standardLevel;
|
||||
private String uniqueWord;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ import com.chint.infrastructure.util.PageResult;
|
|||
import com.chint.infrastructure.util.Result;
|
||||
import com.sun.net.httpserver.Authenticator;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -68,16 +70,17 @@ public class RankController {
|
|||
|
||||
@ApiOperation("保存等级")
|
||||
@PostMapping("/save")
|
||||
public Result<Ranks> saveRanks(@RequestBody RanksDto dto) {
|
||||
public Result<Ranks> saveRanks(@Valid @RequestBody RanksDto dto) {
|
||||
Ranks ranks=new Ranks();
|
||||
BeanUtils.copyProperties(dto,ranks);
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, jdbcRanksRepository.save(ranks));
|
||||
ranks.setUniqueWord(dto.getRankName() + "-" + dto.getCompanyCode());
|
||||
Ranks save = null;
|
||||
try {
|
||||
save = ranksRepository.save(ranks);
|
||||
} catch (Exception e) {
|
||||
throw new DuplicateException(CommonMessageConstant.DUPLICATE_ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation("修改等级")
|
||||
@PostMapping("/update")
|
||||
public Result<Ranks> updateRanks(@RequestBody Ranks ranks) {
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, jdbcRanksRepository.save(ranks));
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, save);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -8,14 +8,14 @@ import com.chint.infrastructure.util.PageResult;
|
|||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.route.service.UserDepartmentInfoBasicService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||
|
||||
@RestController
|
||||
|
@ -28,27 +28,21 @@ public class StaffRankController {
|
|||
@Autowired
|
||||
private UserDepartmentInfoBasicService userDepartmentInfoBasicService;
|
||||
|
||||
@ApiOperation("新增职级")
|
||||
@ApiOperation("保存职级")
|
||||
@PostMapping("/save")
|
||||
public Result<Object> save(@RequestBody @Valid StaffRankData staffRankData) {
|
||||
public Result<Object> save(@Valid @RequestBody StaffRankData staffRankData) {
|
||||
StaffRank staffRank = new StaffRank();
|
||||
BeanUtils.copyProperties(staffRankData,staffRank);
|
||||
return Result.Success(SUCCESS, jdbcStaffRankRepository.save(staffRank));
|
||||
}
|
||||
|
||||
@ApiOperation("新增职级")
|
||||
@ApiOperation("删除职级")
|
||||
@PostMapping("/delete/{id}")
|
||||
public Result<Object> delete(@PathVariable("id")Integer id) {
|
||||
jdbcStaffRankRepository.deleteById(id);
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation("修改职级")
|
||||
@PostMapping("/update")
|
||||
public Result<Object> save(@RequestBody @Valid StaffRank staffRank) {
|
||||
return Result.Success(SUCCESS, jdbcStaffRankRepository.save(staffRank));
|
||||
}
|
||||
|
||||
@ApiOperation("职级分页查询")
|
||||
@PostMapping("/pageQuery")
|
||||
public Result<PageResult<?>> save(@RequestBody StaffRankQuery staffRankQuery) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class StaffRankData {
|
||||
private Integer id;
|
||||
@NotNull
|
||||
private String employeeNo;
|
||||
//员工名称
|
||||
|
|
Loading…
Reference in New Issue