feat: manage school organization mode
parent
a11fb0c8d0
commit
1c7ae68ffd
@ -0,0 +1,36 @@
|
||||
package com.sztzjy.linkCommerce.controller;
|
||||
|
||||
import com.sztzjy.linkCommerce.config.exception.UnAuthorizedException;
|
||||
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||||
import com.sztzjy.linkCommerce.config.security.TokenProvider;
|
||||
import com.sztzjy.linkCommerce.entity.SchoolProductConfig;
|
||||
import com.sztzjy.linkCommerce.service.SchoolProductConfigService;
|
||||
import com.sztzjy.linkCommerce.util.ResultEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Api(tags = "学校产品配置")
|
||||
@RestController
|
||||
@RequestMapping("api/school-product-config")
|
||||
public class SchoolProductConfigController {
|
||||
@Autowired
|
||||
private SchoolProductConfigService schoolProductConfigService;
|
||||
|
||||
@GetMapping("/current")
|
||||
@ApiOperation("当前用户学校产品配置")
|
||||
public ResultEntity<SchoolProductConfig> current(HttpServletRequest request) {
|
||||
JwtUser user = TokenProvider.getJWTUser(request);
|
||||
if (user == null || StringUtils.isBlank(user.getSchoolId())) {
|
||||
throw new UnAuthorizedException("当前用户缺少学校信息");
|
||||
}
|
||||
return new ResultEntity<>(HttpStatus.OK, "查询成功", schoolProductConfigService.getRequiredConfig(user.getSchoolId()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.sztzjy.linkCommerce.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class SchoolProductConfigControllerTest {
|
||||
@Test
|
||||
void exposesCurrentSchoolConfigurationEndpoint() {
|
||||
assertTrue(Arrays.stream(SchoolProductConfigController.class.getDeclaredMethods())
|
||||
.anyMatch(method -> method.isAnnotationPresent(GetMapping.class)
|
||||
&& Arrays.asList(method.getAnnotation(GetMapping.class).value()).contains("/current")));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue