|
@@ -9,11 +9,17 @@ import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
|
|
|
import com.mooctest.crowd.site.command.AuthRejectCommand;
|
|
|
import com.mooctest.crowd.site.command.GenerateAgencyCommand;
|
|
|
import com.mooctest.crowd.site.data.dto.UserDTO;
|
|
|
+import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
|
+import com.mooctest.crowd.site.data.response.ServerCode;
|
|
|
import com.mooctest.crowd.site.data.vo.AgencyVO;
|
|
|
import com.mooctest.crowd.site.data.vo.EvolutionAgencyVO;
|
|
|
+import com.mooctest.crowd.site.data.vo.SearchConditionVO;
|
|
|
import com.mooctest.crowd.site.service.AgencyService;
|
|
|
+import com.mooctest.crowd.site.util.DataUtils;
|
|
|
import lombok.extern.java.Log;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -29,18 +35,19 @@ import java.util.List;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/api")
|
|
|
-public class AgencyController {
|
|
|
+public class AgencyController extends BaseSearchController {
|
|
|
|
|
|
@Autowired
|
|
|
private AgencyService agencyService;
|
|
|
|
|
|
/**
|
|
|
* 绿色通道:未登录情况直接录入认证信息,生成用户和评测机构信息
|
|
|
+ *
|
|
|
* @param command
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/greenChannel/agency", method = RequestMethod.POST)
|
|
|
- public UserDTO generateAgency(@RequestBody @Validated GenerateAgencyCommand command, BindingResult result){
|
|
|
+ public UserDTO generateAgency(@RequestBody @Validated GenerateAgencyCommand command, BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
return agencyService.generateAgency(command);
|
|
@@ -48,6 +55,7 @@ public class AgencyController {
|
|
|
|
|
|
/**
|
|
|
* 申请机构认证
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -55,7 +63,7 @@ public class AgencyController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.POST)
|
|
|
- public UserDTO applyAgencyAuth(@PathVariable("userId") Long userId, @RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result){
|
|
|
+ public UserDTO applyAgencyAuth(@PathVariable("userId") Long userId, @RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
return agencyService.applyAgency(userId, command);
|
|
@@ -63,6 +71,7 @@ public class AgencyController {
|
|
|
|
|
|
/**
|
|
|
* 更新机构认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -70,7 +79,7 @@ public class AgencyController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.PUT)
|
|
|
- public AgencyVO updateAgencyInfo(@PathVariable("userId") Long userId, @RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result){
|
|
|
+ public AgencyVO updateAgencyInfo(@PathVariable("userId") Long userId, @RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
return agencyService.updateAgencyInfo(userId, command);
|
|
@@ -78,13 +87,14 @@ public class AgencyController {
|
|
|
|
|
|
/**
|
|
|
* 审核认证请求(修改认证申请的状态)
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency/status/", method = RequestMethod.PUT)
|
|
|
- public UserDTO checkAuth(@PathVariable("userId") Long userId, @PathVariable("status") Integer status){
|
|
|
+ public UserDTO checkAuth(@PathVariable("userId") Long userId, @PathVariable("status") Integer status) {
|
|
|
if (status > 1 || status < -1)
|
|
|
throw new BaseException("错误的状态信息,无法更新认证状态为所选状态");
|
|
|
return agencyService.updateAgencyStatus(userId, status);
|
|
@@ -93,26 +103,27 @@ public class AgencyController {
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency/status/accept", method = RequestMethod.PUT)
|
|
|
- public AgencyVO passAuth(@PathVariable("userId") Long userId){
|
|
|
+ public AgencyVO passAuth(@PathVariable("userId") Long userId) {
|
|
|
return agencyService.passAuth(userId);
|
|
|
}
|
|
|
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency/status/reject", method = RequestMethod.PUT)
|
|
|
- public AgencyVO rejectAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command){
|
|
|
+ public AgencyVO rejectAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command) {
|
|
|
return agencyService.rejectAuth(userId, command.getExplain());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 测评机构修改能力和资源信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency/resource", method = RequestMethod.POST)
|
|
|
- public AgencyVO updateAgencyResourceAndAbility(@PathVariable("userId") Long userId, @RequestBody @Validated AgencyResourceAbilityUpdateCommand command, BindingResult result){
|
|
|
+ public AgencyVO updateAgencyResourceAndAbility(@PathVariable("userId") Long userId, @RequestBody @Validated AgencyResourceAbilityUpdateCommand command, BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
return agencyService.upadteResourceAndAbility(userId, command);
|
|
@@ -120,17 +131,33 @@ public class AgencyController {
|
|
|
|
|
|
/**
|
|
|
* 获取机构认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.GET)
|
|
|
- public AgencyVO getAgencyInfo(@PathVariable("userId") Long userId){
|
|
|
+ public AgencyVO getAgencyInfo(@PathVariable("userId") Long userId) {
|
|
|
return agencyService.getAgencyDetails(userId);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/agency/list", method = RequestMethod.GET)
|
|
|
- public List<EvolutionAgencyVO> getAgencyList(){
|
|
|
+ public List<EvolutionAgencyVO> getAgencyList() {
|
|
|
return agencyService.getAgencyList();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/agency/list/more", method = RequestMethod.GET)
|
|
|
+ public ResponseVO getMoreAgencyList(@RequestBody SearchConditionVO searchConditionVO) {
|
|
|
+ Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
+ List<EvolutionAgencyVO> list = agencyService.findMoreAgencyVO();
|
|
|
+ Page<EvolutionAgencyVO> page = DataUtils.listToPage(list, pageable);
|
|
|
+ return new ResponseVO(ServerCode.SUCCESS, page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<?> search(String searchCondition) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|