|
@@ -2,19 +2,8 @@ package com.qmth.distributed.print.api;
|
|
|
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.boot.core.solar.crypto.AppLicenseUtil;
|
|
|
-import com.qmth.boot.core.solar.model.AppControl;
|
|
|
-import com.qmth.boot.core.solar.model.AppInfo;
|
|
|
-import com.qmth.boot.core.solar.service.SolarService;
|
|
|
-import com.qmth.boot.tools.device.DeviceInfo;
|
|
|
import com.qmth.distributed.print.business.bean.dto.TSAuthDto;
|
|
|
-import com.qmth.distributed.print.business.entity.TSAuth;
|
|
|
-import com.qmth.distributed.print.business.service.TSAuthService;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
-import com.qmth.teachcloud.common.util.Result;
|
|
|
-import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -23,19 +12,13 @@ import io.swagger.annotations.ApiResponses;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import javax.validation.Valid;
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLEncoder;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -48,70 +31,20 @@ import java.net.URLEncoder;
|
|
|
@Api(tags = "授权配置Controller")
|
|
|
@RestController
|
|
|
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.auth}")
|
|
|
-//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
|
|
|
@Validated
|
|
|
public class TSAuthController {
|
|
|
private final static Logger log = LoggerFactory.getLogger(TSAuthController.class);
|
|
|
|
|
|
- @Resource
|
|
|
- TSAuthService tsAuthService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- SolarService solarService;
|
|
|
-
|
|
|
- @ApiOperation(value = "授权配置信息")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "授权配置信息", response = TSAuthDto.class)})
|
|
|
- @RequestMapping(value = "/info", method = RequestMethod.POST)
|
|
|
- public Result info() {
|
|
|
- Long schoolId = SystemConstant.getHeadOrUserSchoolId();
|
|
|
- return ResultUtil.ok(true);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "保存或更新授权配置信息")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "授权配置信息", response = TSAuth.class)})
|
|
|
- @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
- public void save(@Valid @RequestBody TSAuth tsAuth, BindingResult bindingResult) {
|
|
|
-// if (bindingResult.hasErrors()) {
|
|
|
-// return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
-// }
|
|
|
- Long schoolId = SystemConstant.getHeadOrUserSchoolId();
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
- log.info("DeviceInfo.current():{}", JacksonUtil.parseJson(DeviceInfo.current()));
|
|
|
- log.info("deviceInfo.getComputer():{}", JacksonUtil.parseJson(deviceInfo.getComputer()));
|
|
|
- log.info("deviceInfo.getDiskStore():{}", JacksonUtil.parseJson(deviceInfo.getDiskStore()));
|
|
|
- log.info("deviceInfo.getNetworkInterface():{}", JacksonUtil.parseJson(deviceInfo.getNetworkInterface()));
|
|
|
- log.info("deviceInfo.getProcessor():{}", JacksonUtil.parseJson(deviceInfo.getProcessor()));
|
|
|
- log.info("deviceInfo.uuid():{}", deviceInfo.uuid());
|
|
|
-
|
|
|
- AppControl appControl = solarService.getAppControl();
|
|
|
- log.info("appControl:{}", JacksonUtil.parseJson(appControl));
|
|
|
-// List<OrgInfo> orgInfoList = solarService.getOrgList();
|
|
|
-// log.info("orgInfoList:{}", JacksonUtil.parseJson(orgInfoList));
|
|
|
- AppInfo appInfo = solarService.getAppInfo();
|
|
|
- log.info("appInfo:{}", JacksonUtil.parseJson(appInfo));
|
|
|
-// solarService.update();
|
|
|
+ @ApiOperation(value = "导出硬件信息")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "导出硬件信息", response = TSAuthDto.class)})
|
|
|
+ @RequestMapping(value = "/export/device/info", method = RequestMethod.POST)
|
|
|
+ public void info() {
|
|
|
try {
|
|
|
-// ByteArray byteArray = AppLicenseUtil.buildDeviceInfo();
|
|
|
-// log.info("byteArray:{}", byteArray.value());
|
|
|
-// solarService.update(byteArray.value());
|
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=" + urlEncode("device.info"));
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + SystemConstant.urlEncode("device.info"));
|
|
|
IOUtils.copy(new ByteArrayInputStream(AppLicenseUtil.buildDeviceInfo().value()), response.getOutputStream());
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-// return ResultUtil.ok(true);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * URL 编码, Encode默认为UTF-8.
|
|
|
- */
|
|
|
- public static String urlEncode(String part) {
|
|
|
- try {
|
|
|
- return URLEncoder.encode(part, SystemConstant.CHARSET_NAME);
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
}
|
|
|
}
|
|
|
}
|