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