|
@@ -1,12 +1,33 @@
|
|
package com.qmth.distributed.print.api.mark;
|
|
package com.qmth.distributed.print.api.mark;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.Set;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.qmth.distributed.print.business.bean.params.ClientLoginParam;
|
|
|
|
+import com.qmth.distributed.print.business.service.ClientService;
|
|
|
|
+import com.qmth.teachcloud.common.bean.result.LoginClientResult;
|
|
|
|
+import com.qmth.teachcloud.common.bean.result.LoginResult;
|
|
|
|
+import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
|
+import com.qmth.teachcloud.common.enums.AppSourceEnum;
|
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
|
+import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
|
+import com.qmth.teachcloud.common.util.*;
|
|
|
|
+import io.swagger.annotations.*;
|
|
|
|
+import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -18,15 +39,9 @@ import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.TBSession;
|
|
import com.qmth.teachcloud.common.entity.TBSession;
|
|
import com.qmth.teachcloud.common.service.BasicSemesterService;
|
|
import com.qmth.teachcloud.common.service.BasicSemesterService;
|
|
-import com.qmth.teachcloud.common.util.AuthUtil;
|
|
|
|
-import com.qmth.teachcloud.common.util.RedisUtil;
|
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
import com.qmth.teachcloud.mark.bean.sys.ActiveTimeVo;
|
|
import com.qmth.teachcloud.mark.bean.sys.ActiveTimeVo;
|
|
import com.qmth.teachcloud.mark.bean.sys.ApiStatusVo;
|
|
import com.qmth.teachcloud.mark.bean.sys.ApiStatusVo;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 扫描系统相关 前端控制器
|
|
* 扫描系统相关 前端控制器
|
|
@@ -43,10 +58,52 @@ public class ScanController {
|
|
@Resource
|
|
@Resource
|
|
BasicSemesterService basicSemesterService;
|
|
BasicSemesterService basicSemesterService;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private TeachcloudCommonService teachcloudCommonService;
|
|
|
|
+ @Resource
|
|
|
|
+ private CommonCacheService commonCacheService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ClientService clientService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
+ @Resource
|
|
private SysProperty sysProperty;
|
|
private SysProperty sysProperty;
|
|
@Resource
|
|
@Resource
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 登录
|
|
|
|
+ *
|
|
|
|
+ * @param login 登录参数
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = "登录")
|
|
|
|
+ @PostMapping("/login")
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
|
|
|
|
+ @Aac(auth = false)
|
|
|
|
+ public Result login(@ApiParam(value = "用户信息", required = true) @Valid @RequestBody ClientLoginParam login, BindingResult bindingResult) throws NoSuchAlgorithmException {
|
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
|
+ return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
|
+ }
|
|
|
|
+ BasicSchool basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
|
|
|
|
+ if (Objects.isNull(basicSchool)) {
|
|
|
|
+ throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId()).eq(SysUser::getLoginName, login.getLoginName());
|
|
|
|
+ SysUser sysUser = sysUserService.getOne(wrapper);
|
|
|
|
+ // 用户不存在或密码错误
|
|
|
|
+ if (Objects.isNull(sysUser) || !Objects.equals(sysUser.getPassword(), login.getPassword())) {
|
|
|
|
+ throw ExceptionResultEnum.USER_NO_DATA.exception();
|
|
|
|
+ }
|
|
|
|
+ // 是否有打印端和扫描端权限
|
|
|
|
+ Set<String> roles = clientService.getRoleByUserId(sysUser.getId());
|
|
|
|
+
|
|
|
|
+ LoginResult loginResult = teachcloudCommonService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM);
|
|
|
|
+ LoginClientResult loginClientResult = new LoginClientResult(sysUser, loginResult);
|
|
|
|
+ loginClientResult.setRoleList(roles);
|
|
|
|
+ // todo 是否可以新增卡格式
|
|
|
|
+ return ResultUtil.ok(new LoginClientResult(sysUser, loginResult));
|
|
|
|
+ }
|
|
|
|
+
|
|
@Aac(auth = false)
|
|
@Aac(auth = false)
|
|
@ApiOperation(value = "服务端状态")
|
|
@ApiOperation(value = "服务端状态")
|
|
@RequestMapping("server/status")
|
|
@RequestMapping("server/status")
|
|
@@ -57,14 +114,14 @@ public class ScanController {
|
|
vo.setTime(System.currentTimeMillis());
|
|
vo.setTime(System.currentTimeMillis());
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@ApiOperation(value = "心跳接口")
|
|
@ApiOperation(value = "心跳接口")
|
|
@PostMapping("server/heartbeat")
|
|
@PostMapping("server/heartbeat")
|
|
public ActiveTimeVo heartbeat() {
|
|
public ActiveTimeVo heartbeat() {
|
|
Platform platform = ServletUtil.getRequestPlatform();
|
|
Platform platform = ServletUtil.getRequestPlatform();
|
|
ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
|
|
ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
|
|
- TBSession ts=(TBSession)ServletUtil.getRequestSession();
|
|
|
|
- redisUtil.expire(ts.getId(), expireTime.getExpireSeconds(),TimeUnit.SECONDS);
|
|
|
|
|
|
+ TBSession ts = (TBSession) ServletUtil.getRequestSession();
|
|
|
|
+ redisUtil.expire(ts.getId(), expireTime.getExpireSeconds(), TimeUnit.SECONDS);
|
|
ActiveTimeVo vo = new ActiveTimeVo();
|
|
ActiveTimeVo vo = new ActiveTimeVo();
|
|
vo.setActiveTime(System.currentTimeMillis());
|
|
vo.setActiveTime(System.currentTimeMillis());
|
|
return vo;
|
|
return vo;
|