1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-10-07 00:15:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

添加测试类,去除多余的import

This commit is contained in:
2022-04-04 00:47:14 +08:00
parent 1b2d61723e
commit 8d30e4898d
8 changed files with 84 additions and 40 deletions

View File

@@ -0,0 +1,41 @@
package plus.bookshelf.Controller.Controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import plus.bookshelf.Common.Error.BusinessErrorCode;
import plus.bookshelf.Common.Error.BusinessException;
import plus.bookshelf.Common.Response.CommonReturnType;
import plus.bookshelf.Common.ThirdParty.ThirdPartyConfig;
import plus.bookshelf.Service.Impl.UserServiceImpl;
import plus.bookshelf.Service.Model.UserModel;
import java.util.Objects;
@Api(tags = "系统调试接口")
@Controller("debug")
@RequestMapping("/debug")
public class DebugController extends BaseController {
@Autowired
ThirdPartyConfig thirdPartyConfig;
@Autowired
UserServiceImpl userService;
@ApiOperation(value = "获取系统配置", notes = "仅限管理员登录状态下可获取")
@RequestMapping(value = "status", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType status(@RequestParam(value = "token", required = false) String token) throws BusinessException {
UserModel userModel = userService.getUserByToken(redisTemplate, token);
if (userModel == null || !Objects.equals(userModel.getGroup(), "ADMIN")) {
throw new BusinessException(BusinessErrorCode.OPERATION_NOT_ALLOWED, "非管理员用户无权进行此操作");
}
return CommonReturnType.create(thirdPartyConfig);
}
}