Commit 00fbc440 authored by zhangc's avatar zhangc

修复启动异常

parent 8684ae6f
package com.jz.common.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* @ClassName: 将数据从session存储/取出
* @Author: Carl
* @Date: 2020/12/2
* @Version:
*/
public class UserContextUtil {
/**
* 从session中获取数据
* @param objName 存储到session中的对象的变量名
*/
public static Object pop(String objName) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request.getSession().getAttribute(objName);
}
/**
* 把数据存储到session中
* @param objName 存储到session中的对象的变量名
* @param o 存储的任意数据
*/
public static void push(String objName, Object o) {
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
request.getSession().setAttribute(objName, o);
}
}
......@@ -52,11 +52,11 @@ public class CompanyAuthController {
*/
@GetMapping("/findCompany")
@ApiOperation(value = "企业认证信息查询")
public Mono<Result> selectCompany(HttpServletRequest httpRequest) {
public Mono<Result> selectCompany(@RequestParam(value = "type") String type) {
return Mono.fromSupplier(() ->{
//TODO 获取当前登录用户
//httpRequest.getSession().getServletContext().getAttribute("customer_id");
return Result.ok(companyAuthService.selectCompany());
return Result.ok(companyAuthService.selectCompany(type));
});
}
}
......@@ -2,7 +2,6 @@ package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.common.utils.UserContextUtil;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import io.swagger.annotations.Api;
......
package com.jz.dm.mall.moduls.controller.customer;
import com.aliyuncs.exceptions.ClientException;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.utils.Result;
import com.jz.common.utils.SMSUtils;
import com.jz.common.utils.ValidateCodeUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
/**
* @ClassName: 短信发送接口
* @Author: Carl
* @Date: 2020/12/2
* @Version:
*/
@RestController
@RequestMapping("/validateCode")
@Api(tags = "短信发送api")
public class ValidateCodeController {
@Autowired
private JedisPool jedisPool;
/**
* 注册时发送的验证码
* @param telephone
* @return
*/
@PostMapping("/send4Login")
public Result send4Login(String telephone) {
// 查询redis里是否存在该手机号
Jedis jedis = jedisPool.getResource();
String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
String codeInRedis = jedis.get(key);
if (codeInRedis != null && !codeInRedis.equals("")) {
// redis中的数据还未过期
return new Result(false, "验证码已发送,请注意查收!");
}else {
Integer code = ValidateCodeUtils.generateValidateCode(6);
try {
SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
} catch (Exception e) {
e.printStackTrace();
}
jedis.setex(key,5*60,code+"");
return new Result(true, "验证码发送成功!");
}
}
/**
* 修改密码发送验证码
* @param telephone
* @return
*/
@PostMapping("/send4Code")
public Result send4Code(String telephone) {
// 查询redis里是否存在该手机号
Jedis jedis = jedisPool.getResource();
String key = RedisMessageConstant.SENDTYPE_GETPWD + "_" + telephone;
String codeInRedis = jedis.get(key);
if (codeInRedis != null && !codeInRedis.equals("")) {
// redis中的数据还未过期
return new Result(false, "验证码已发送,请注意查收!");
}else {
Integer code = ValidateCodeUtils.generateValidateCode(6);
try {
SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
} catch (Exception e) {
e.printStackTrace();
}
jedis.setex(key,5*60,code+"");
return new Result(true, "验证码发送成功!");
}
}
}
//package com.jz.dm.mall.moduls.controller.customer;
//
//import com.aliyuncs.exceptions.ClientException;
//import com.jz.common.constant.RedisMessageConstant;
//import com.jz.common.utils.Result;
//import com.jz.common.utils.SMSUtils;
//import com.jz.common.utils.ValidateCodeUtils;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import redis.clients.jedis.Jedis;
//import redis.clients.jedis.JedisPool;
//
///**
// * @ClassName: 短信发送接口
// * @Author: Carl
// * @Date: 2020/12/2
// * @Version:
// */
//@RestController
//@RequestMapping("/validateCode")
//@Api(tags = "短信发送api")
//public class ValidateCodeController {
//
// //@Autowired
// //private JedisPool jedisPool;
//
// /**
// * 注册时发送的验证码
// * @param telephone
// * @return
// */
// @PostMapping("/send4Login")
// public Result send4Login(String telephone) {
// // 查询redis里是否存在该手机号
// Jedis jedis = jedisPool.getResource();
// String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
// String codeInRedis = jedis.get(key);
// if (codeInRedis != null && !codeInRedis.equals("")) {
// // redis中的数据还未过期
// return new Result(false, "验证码已发送,请注意查收!");
// }else {
// Integer code = ValidateCodeUtils.generateValidateCode(6);
// try {
// SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// jedis.setex(key,5*60,code+"");
// return new Result(true, "验证码发送成功!");
// }
// }
//
// /**
// * 修改密码发送验证码
// * @param telephone
// * @return
// */
// @PostMapping("/send4Code")
// public Result send4Code(String telephone) {
// // 查询redis里是否存在该手机号
// Jedis jedis = jedisPool.getResource();
// String key = RedisMessageConstant.SENDTYPE_GETPWD + "_" + telephone;
// String codeInRedis = jedis.get(key);
// if (codeInRedis != null && !codeInRedis.equals("")) {
// // redis中的数据还未过期
// return new Result(false, "验证码已发送,请注意查收!");
// }else {
// Integer code = ValidateCodeUtils.generateValidateCode(6);
// try {
// SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// jedis.setex(key,5*60,code+"");
// return new Result(true, "验证码发送成功!");
// }
// }
//}
package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
......
......@@ -24,9 +24,10 @@ public interface CompanyAuthService {
/**
* 查询企业认证详情
* @param type
* @return
*/
Result<Department> selectCompany();
Result<Department> selectCompany(String type);
}
package com.jz.dm.mall.moduls.service;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import java.util.Map;
......
......@@ -3,9 +3,8 @@ import java.math.BigDecimal;
import com.jz.common.entity.Department;
import com.jz.common.entity.FinanceCustomerAssets;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.common.utils.Result;
import com.jz.common.utils.UserContextUtil;
import com.jz.dm.mall.moduls.controller.company.bean.CompanyAddReq;
import com.jz.dm.mall.moduls.mapper.DepartmentDao;
import com.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao;
......@@ -53,7 +52,8 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
public Result addCompanyData(CompanyAddReq req) {
//TODO 获取当前用户ID判断当前用户是否已经关联企业
Long customerId = (Long) UserContextUtil.pop("customer_id");
// Long customerId = (Long) UserContextUtil.pop("customer_id");
Long customerId = 0L;
if (null ==customerId){
return Result.error("获取用户信息失败");
}
......@@ -78,13 +78,19 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
/**
* 查询企业认证详情
* @param type
* @return
*/
@Override
public Result<Department> selectCompany() {
public Result<Department> selectCompany(String type) {
//查询用户判断用户是否认证
// if (){
//
// Long customerId = (Long) UserContextUtil.pop("customer_id");
// if (null ==customerId){
// return Result.error("获取用户信息失败");
// }
// MallCustomer mallCustomer = mallCustomerDao.findById(customerId);
// if (null == mallCustomer){
// return Result.error("用户信息不存在");
// }
return null;
}
......@@ -116,7 +122,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
mallCustomer.setCustomerId(req.getCustomerId());//用户ID
mallCustomer.setDepartmentId(departmentInset.getDepartmentId());
mallCustomer.setUptTime(new Date());
mallCustomer.setUptPerson(req.getLoginName());
// mallCustomer.setUptPerson(req.getLoginName());
if (mallCustomerDao.updateById(mallCustomer) != 1){
throw new RuntimeException("更新用户企业信息失败");
}
......
package com.jz.dm.mall.moduls.service.impl;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.mapper.MallCustomerDao;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,7 +26,6 @@ public class MallCustomerServiceImpl implements MallCustomerService {
*/
@Override
public MallCustomer selectByAccount(String username) {
return tMallCustomerDao.selectByAccount(username);
}
......
......@@ -206,18 +206,18 @@
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat-embed-core.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-web.version}</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.tomcat.embed</groupId>-->
<!-- <artifactId>tomcat-embed-core</artifactId>-->
<!-- <version>${tomcat-embed-core.version}</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-web</artifactId>-->
<!-- <version>${spring-web.version}</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
</dependencyManagement>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment