中继服务同步,注册码,代码备份,
parent
2afe0d9c23
commit
0b38bfd616
@ -0,0 +1,69 @@
|
||||
package com.glxp.sale.admin.controller.auth;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.sale.admin.entity.auth.AuthCheckEntity;
|
||||
import com.glxp.sale.admin.req.auth.AuthCheckRequest;
|
||||
import com.glxp.sale.admin.res.PageSimpleResponse;
|
||||
import com.glxp.sale.admin.service.auth.AuthCheckService;
|
||||
import com.glxp.sale.admin.util.RsaUtils;
|
||||
import com.glxp.sale.common.enums.ResultEnum;
|
||||
import com.glxp.sale.common.res.BaseResponse;
|
||||
import com.glxp.sale.common.util.ResultVOUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class AuthCheckController {
|
||||
|
||||
@Resource
|
||||
private AuthCheckService authCheckService;
|
||||
|
||||
@GetMapping("/udiwms/auth/device/filter")
|
||||
public BaseResponse index(AuthCheckRequest authCheckRequest,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
List<AuthCheckEntity> authCheckEntityList = authCheckService.filterDevices(authCheckRequest);
|
||||
|
||||
PageInfo<AuthCheckEntity> authCheckEntityPageInfo = new PageInfo<>(authCheckEntityList);
|
||||
PageSimpleResponse<AuthCheckEntity> authAdminResponseList = new PageSimpleResponse<>();
|
||||
authAdminResponseList.setTotal(authCheckEntityPageInfo.getTotal());
|
||||
authAdminResponseList.setList(authCheckEntityList);
|
||||
|
||||
return ResultVOUtils.success(authAdminResponseList);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/udiwms/auth/device/save")
|
||||
public BaseResponse save(@RequestBody @Valid AuthCheckEntity authCheckEntity,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
String key = null;
|
||||
try {
|
||||
key = RsaUtils.publicKeyDecrypt(authCheckEntity.getRegisterCode(), RsaUtils.publicKey);
|
||||
if (key != null && key.equals(authCheckEntity.getMachineInfo())) {
|
||||
authCheckService.updateDevices(authCheckEntity);
|
||||
return ResultVOUtils.success("注册成功!");
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "注册失败,注册码不匹配!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ResultVOUtils.error(500, "注册失败!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.glxp.sale.admin.dao.auth;
|
||||
|
||||
import com.glxp.sale.admin.entity.auth.AuthCheckEntity;
|
||||
import com.glxp.sale.admin.req.auth.AuthCheckRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AuthCheckDao {
|
||||
|
||||
List<AuthCheckEntity> filterDevices(AuthCheckRequest authCheckRequest);
|
||||
|
||||
AuthCheckEntity findByMachine(String machineInfo);
|
||||
|
||||
boolean insertDevices(AuthCheckEntity authCheckEntity);
|
||||
|
||||
boolean updateDevices(AuthCheckEntity authCheckEntity);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.glxp.sale.admin.entity.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AuthCheckEntity {
|
||||
private Integer id;
|
||||
private String machineInfo;
|
||||
private String remark;
|
||||
private String registerCode;
|
||||
private Date createDate;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.glxp.sale.admin.req.auth;
|
||||
|
||||
import com.glxp.sale.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthCheckRequest extends ListPageRequest {
|
||||
|
||||
private Integer id;
|
||||
private String machineInfo;
|
||||
private String registerCode;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.glxp.sale.admin.req.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
public class PCLoginRequest {
|
||||
|
||||
@NotEmpty(message = "用户名不能为空")
|
||||
private String username;
|
||||
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
// @NotEmpty(message = "机器码不能为空")
|
||||
private String machineInfo;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.glxp.sale.admin.res.basic;
|
||||
|
||||
import com.glxp.sale.admin.entity.basic.UdiCompanyEntity;
|
||||
import com.glxp.sale.admin.entity.receipt.ProductInfoEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SpSyncUdiResponse {
|
||||
|
||||
List<ProductInfoEntity> productInfoEntityList;
|
||||
List<UdiCompanyEntity> udiCompanyEntities;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.glxp.sale.admin.service.auth;
|
||||
|
||||
|
||||
import com.glxp.sale.admin.entity.auth.AuthCheckEntity;
|
||||
import com.glxp.sale.admin.req.auth.AuthCheckRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthCheckService {
|
||||
|
||||
AuthCheckEntity findByMachine(String machineInfo);
|
||||
|
||||
List<AuthCheckEntity> filterDevices(AuthCheckRequest authCheckRequest);
|
||||
|
||||
boolean insertDevices(AuthCheckEntity authCheckEntity);
|
||||
|
||||
boolean updateDevices(AuthCheckEntity authCheckEntity);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.glxp.sale.admin.service.auth.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.sale.admin.dao.auth.AuthCheckDao;
|
||||
import com.glxp.sale.admin.entity.auth.AuthCheckEntity;
|
||||
import com.glxp.sale.admin.req.auth.AuthCheckRequest;
|
||||
import com.glxp.sale.admin.service.auth.AuthCheckService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AuthCheckServiceImpl implements AuthCheckService {
|
||||
@Resource
|
||||
private AuthCheckDao authCheckDao;
|
||||
|
||||
@Override
|
||||
public AuthCheckEntity findByMachine(String machineInfo) {
|
||||
return authCheckDao.findByMachine(machineInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthCheckEntity> filterDevices(AuthCheckRequest authCheckRequest) {
|
||||
if (authCheckRequest == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (authCheckRequest.getPage() != null) {
|
||||
int offset = (authCheckRequest.getPage() - 1) * authCheckRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, authCheckRequest.getLimit());
|
||||
}
|
||||
return authCheckDao.filterDevices(authCheckRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertDevices(AuthCheckEntity authCheckEntity) {
|
||||
return authCheckDao.insertDevices(authCheckEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDevices(AuthCheckEntity authCheckEntity) {
|
||||
return authCheckDao.updateDevices(authCheckEntity);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.glxp.sale.admin.dao.auth.AuthCheckDao">
|
||||
|
||||
<select id="filterDevices" parameterType="com.glxp.sale.admin.req.auth.AuthCheckRequest"
|
||||
resultType="com.glxp.sale.admin.entity.auth.AuthCheckEntity">
|
||||
SELECT *
|
||||
FROM auth_device_check
|
||||
<where>
|
||||
<if test="machineInfo != null">
|
||||
AND machineInfo = #{machineInfo}
|
||||
</if>
|
||||
<if test="registerCode != null">
|
||||
AND registerCode = #{registerCode}
|
||||
</if>
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY id
|
||||
DESC
|
||||
</select>
|
||||
|
||||
<select id="findByMachine" parameterType="hashmap" resultType="com.glxp.sale.admin.entity.auth.AuthCheckEntity">
|
||||
SELECT *
|
||||
FROM auth_device_check
|
||||
<where>
|
||||
machineInfo = #{machineInfo}
|
||||
</where>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertDevices" keyProperty="id" parameterType="com.glxp.sale.admin.entity.auth.AuthCheckEntity">
|
||||
INSERT INTO auth_device_check
|
||||
(machineInfo, remark, registerCode, createDate)
|
||||
values (#{machineInfo},
|
||||
#{remark},
|
||||
#{registerCode}, #{createDate})
|
||||
</insert>
|
||||
|
||||
<update id="updateDevices" parameterType="com.glxp.sale.admin.entity.auth.AuthCheckEntity">
|
||||
UPDATE auth_device_check
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="remark != null">remark=#{remark},</if>
|
||||
<if test="registerCode != null">registerCode=#{registerCode},</if>
|
||||
<if test="createDate != null">createDate=#{createDate},</if>
|
||||
|
||||
</trim>
|
||||
WHERE machineInfo=#{machineInfo}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue