【add】职级维护功能新增,新增spring-boot-starter-validation校验依赖
This commit is contained in:
parent
6e10545c36
commit
93c1d3f346
5
pom.xml
5
pom.xml
|
@ -109,7 +109,10 @@
|
||||||
<artifactId>minio</artifactId>
|
<artifactId>minio</artifactId>
|
||||||
<version>8.5.6</version>
|
<version>8.5.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.chint.application.in;
|
||||||
|
|
||||||
|
import com.chint.application.queryies.StaffRankQuery;
|
||||||
|
import com.chint.domain.aggregates.standards.StaffRank;
|
||||||
|
import com.chint.domain.value_object.StaffRankData;
|
||||||
|
import com.chint.infrastructure.repository.jdbc.JdbcStaffRankRepository;
|
||||||
|
import com.chint.infrastructure.util.PageResult;
|
||||||
|
import com.chint.infrastructure.util.Result;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
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.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/staff/rank")
|
||||||
|
public class StaffRankController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcStaffRankRepository jdbcStaffRankRepository;
|
||||||
|
|
||||||
|
@ApiOperation("新增职级")
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Result<Object> save(@RequestBody @Valid StaffRankData staffRankData) {
|
||||||
|
StaffRank staffRank = new StaffRank();
|
||||||
|
BeanUtils.copyProperties(staffRankData,staffRank);
|
||||||
|
return Result.Success(SUCCESS, jdbcStaffRankRepository.save(staffRank));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
PageRequest pageRequest = PageRequest
|
||||||
|
.of(staffRankQuery.getPageNum() - 1, staffRankQuery.getPageSize());
|
||||||
|
Page<StaffRank> page=jdbcStaffRankRepository.findAllByEmployeeNoContainsAndEmployeeNameContains(staffRankQuery.getEmployeeNo(),staffRankQuery.getEmployeeName(),pageRequest);
|
||||||
|
return Result.Success(SUCCESS, PageResult.totalPageNum(page.getTotalElements(), page.getContent()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.chint.application.queryies;
|
||||||
|
|
||||||
|
import com.chint.domain.value_object.BaseQuery;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StaffRankQuery extends BaseQuery {
|
||||||
|
private String employeeNo="";
|
||||||
|
private String employeeName="";
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.chint.domain.value_object;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StaffRankData {
|
||||||
|
@NotNull
|
||||||
|
private String employeeNo;
|
||||||
|
//员工名称
|
||||||
|
@NotNull
|
||||||
|
private String employeeName;
|
||||||
|
//员工职级
|
||||||
|
@NotNull
|
||||||
|
private String employeeLevel;
|
||||||
|
//公司标识:1:集团,2:新能
|
||||||
|
@NotNull
|
||||||
|
private String tag;
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.chint.infrastructure.repository.jdbc;
|
package com.chint.infrastructure.repository.jdbc;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.standards.StaffRank;
|
import com.chint.domain.aggregates.standards.StaffRank;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -10,4 +12,6 @@ import java.util.List;
|
||||||
public interface JdbcStaffRankRepository extends CrudRepository<StaffRank, Integer> {
|
public interface JdbcStaffRankRepository extends CrudRepository<StaffRank, Integer> {
|
||||||
List<StaffRank> findByEmployeeNoAndTag(String employeeNo,String tag);
|
List<StaffRank> findByEmployeeNoAndTag(String employeeNo,String tag);
|
||||||
List<StaffRank> findByEmployeeNo(String employeeNo);
|
List<StaffRank> findByEmployeeNo(String employeeNo);
|
||||||
|
|
||||||
|
Page<StaffRank> findAllByEmployeeNoContainsAndEmployeeNameContains(String employeeNo, String employeeName, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue