Kaynağa Gözat

登录校验,和文件上传接口bug处理

guojia 4 yıl önce
ebeveyn
işleme
e8ec644359

+ 1 - 1
pom.xml

@@ -52,7 +52,7 @@
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
-            <scope>runtime</scope>
+            <version>5.1.46</version>
         </dependency>
 
         <dependency>

+ 0 - 3
src/main/java/com/ebei/device/asset/weixin/auth/LoginFilter.java

@@ -21,9 +21,6 @@ public class LoginFilter  extends HandlerInterceptorAdapter {
         log.debug("==============Pre LoginFilter================");
     	String tokenValue = parseToken(request);
         String method = request.getMethod();
-        if(true) {
-			return true;
-		}
         if("OPTIONS".equals(method)){
             return true;
         }

+ 5 - 6
src/main/java/com/ebei/device/asset/weixin/contorller/LoginController.java

@@ -2,19 +2,18 @@
 package com.ebei.device.asset.weixin.contorller;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ebei.device.asset.weixin.auth.AuthUtils;
 import com.ebei.device.asset.weixin.constant.Constants;
-import com.ebei.device.asset.weixin.model.entity.AssetTask;
 import com.ebei.device.asset.weixin.model.entity.AssetTenantUser;
 import com.ebei.device.asset.weixin.model.vo.AssetTenantUserVO;
 import com.ebei.device.asset.weixin.service.AssetTenantUserService;
 import com.ebei.device.asset.weixin.service.UserSessionManager;
 import com.ebei.device.asset.weixin.util.MD5;
 import com.ebei.device.asset.weixin.util.ResponseEx;
-import io.swagger.annotations.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -60,7 +59,7 @@ public class LoginController {
 
 			/*校验用户登录信息-------------------开始*/
 			boolean isOk = false;
-			if (null != assetTenantUser) {
+			if (null != assetTenantUser && assetTenantUser.getUserAccount() != null) {
 				String pwdReal = assetTenantUser.getPwd();
 				String md5comparePwd = new MD5().getMD5ofStr(pwdReal);
 				if (null != pwd) {
@@ -78,10 +77,10 @@ public class LoginController {
 					result.put("companyId", assetTenantUser.getCompanyId());
 					result.put("userName", assetTenantUser.getUserName());
 					result.put("token", userSessionManager.createToken(assetTenantUser, companyId));
+					resultResponse = ResponseEx.createSuccess("登录成功", result);
 				} else {
 					resultResponse = ResponseEx.createError("无效的公司");
 				}
-				resultResponse = ResponseEx.createSuccess("登录成功", result);
 			} else {
 				resultResponse = ResponseEx.createError("密码错误");
 			}

+ 2 - 1
src/main/java/com/ebei/device/asset/weixin/model/entity/AssetProposalFile.java

@@ -4,6 +4,7 @@ package com.ebei.device.asset.weixin.model.entity;
 
 
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -26,7 +27,7 @@ import java.util.Date;
 public class AssetProposalFile extends Model<AssetProposalFile> {
 
     @ApiModelProperty(value="主键")
-    @TableId(value = "file_id")
+    @TableId(value = "file_id",type = IdType.ID_WORKER_STR)
     private String fileId;
 
     @TableField("proposal_id")

+ 2 - 2
src/main/java/com/ebei/device/asset/weixin/service/impl/AssetProposalServiceImpl.java

@@ -36,7 +36,7 @@ public class AssetProposalServiceImpl extends ServiceImpl<AssetProposalMapper, A
 
         Date date = new Date();
         //保存建议反馈
-        assetProposal.setCompanyId(AuthUtils.getCompanyId());
+//        assetProposal.setCompanyId(AuthUtils.getCompanyId());
         assetProposal.setCreator(AuthUtils.getUserId());
         assetProposal.setCreateDate(date);
         this.baseMapper.insert(assetProposal);
@@ -54,7 +54,7 @@ public class AssetProposalServiceImpl extends ServiceImpl<AssetProposalMapper, A
     @Override
     public Page<AssetProposal> selectAssetProposalList(Page<AssetProposal> page, Map<String, Object> params) {
 
-        params.put("companyId",AuthUtils.getCompanyId());
+//        params.put("companyId",AuthUtils.getCompanyId());
         List<AssetProposal> list = this.baseMapper.selectAssetProposalList(page, params);
 
         if(list != null && list.size()>0){

+ 1 - 1
src/main/java/com/ebei/device/asset/weixin/service/impl/AssetTaskServiceImpl.java

@@ -37,7 +37,7 @@ public class AssetTaskServiceImpl extends ServiceImpl<AssetTaskMapper, AssetTask
     @Override
     public Page<AssetHistoryTask> selectAssetTaskList(Page<AssetHistoryTask> page, Map<String, Object> params) {
 
-        params.put("companyId", AuthUtils.getCompanyId());
+//        params.put("companyId", AuthUtils.getCompanyId());
         List<AssetHistoryTask> list = this.baseMapper.selectAssetTaskList(page,params);
         return page.setRecords(list);
     }

+ 4 - 4
src/main/java/com/ebei/device/asset/weixin/service/impl/AssetTenantUserServiceImpl.java

@@ -54,14 +54,14 @@ public class AssetTenantUserServiceImpl extends ServiceImpl<AssetTenantUserMappe
 
         //判断账号是否唯一
         QueryWrapper<AssetTenantUser> wrapper = new QueryWrapper<>();
-        wrapper.eq("company_id", AuthUtils.getCompanyId());
+//        wrapper.eq("company_id", AuthUtils.getCompanyId());
         wrapper.eq("user_account",assetTenantUser.getUserAccount());
         int num = this.baseMapper.selectCount(wrapper);
         if(num>0){
             throw new BaseException("账号已存在");
         }
 
-        assetTenantUser.setCompanyId(AuthUtils.getCompanyId());
+//        assetTenantUser.setCompanyId(AuthUtils.getCompanyId());
         assetTenantUser.setCreator(AuthUtils.getUserId());
         assetTenantUser.setCreateDate(new Date());
 
@@ -77,7 +77,7 @@ public class AssetTenantUserServiceImpl extends ServiceImpl<AssetTenantUserMappe
 
     @Override
     public Page<AssetTenantUser> selectAssetTenantUserList(Page<AssetTenantUser> page, Map<String, Object> params) {
-        params.put("companyId",AuthUtils.getCompanyId());
+//        params.put("companyId",AuthUtils.getCompanyId());
         List<AssetTenantUser> list = this.baseMapper.selectAssetTenantUserList(page, params);
         if(list != null && list.size()>0){
             for(AssetTenantUser tenantUser : list){
@@ -121,7 +121,7 @@ public class AssetTenantUserServiceImpl extends ServiceImpl<AssetTenantUserMappe
         if(!(oldUser.getUserAccount().equals(assetTenantUser.getUserAccount()))){
             //判断账号是否唯一
             QueryWrapper<AssetTenantUser> wrapper = new QueryWrapper<>();
-            wrapper.eq("company_id",AuthUtils.getCompanyId());
+//            wrapper.eq("company_id",AuthUtils.getCompanyId());
             wrapper.eq("user_account",assetTenantUser.getUserAccount());
             int num = this.baseMapper.selectCount(wrapper);
             if(num>0){

+ 3 - 0
src/main/java/com/ebei/device/asset/weixin/util/FileUploadDownloadUtil.java

@@ -62,6 +62,9 @@ public class FileUploadDownloadUtil {
    public static boolean fileUpload(String uuid,InputStream file,SimpleDateFormat dateFormat,String filename){
 	   OutputStream out = null;
 	   BufferedReader reader = null;
+	   if(filename.length() >50){
+           filename = filename.substring(filename.length()-50,filename.length()-1);
+       }
        try {
        	   CommProperties commProperties = SpringBeanUtil.getBean(CommProperties.class);
        	

+ 1 - 1
src/main/resources/application.yml

@@ -31,7 +31,7 @@ spring:
     url: jdbc:mysql://172.18.0.23:3306/rongsheng_qpi?useUnicode=true&characterEncoding=utf-8&useTimezone=true&serverTimezone=GMT%2B8
     username: root
     password: 1q2w3e4r
-    driver-class-name: com.mysql.cj.jdbc.Driver
+    driver-class-name: com.mysql.jdbc.Driver
     platform: mysql
 
 mybatis-plus: