Compare commits

..

7 Commits

Author SHA1 Message Date
dimengzhe
6166fee301 修改域名 2025-05-12 14:52:22 +08:00
f3b2b7e866 1 2025-05-07 09:56:06 +08:00
062212cffb 1 2025-05-07 08:42:41 +08:00
dimengzhe
79fcf614ca 修改 2025-04-28 10:50:52 +08:00
dimengzhe
fbbe5be935 修改 2025-04-22 17:13:27 +08:00
dimengzhe
66419b39a7 修改 2025-04-22 11:31:49 +08:00
dimengzhe
e4f98271b6 验证码 2025-04-21 22:59:31 +08:00
11 changed files with 80 additions and 13 deletions

View File

@@ -1,8 +1,11 @@
package com.kelp.business;
import com.google.code.kaptcha.Constants;
import com.kelp.business.dao.BuyDao;
import com.kelp.business.entity.Buy;
import com.kelp.common.config.RedisBean;
import com.kelp.common.utils.IdWorker;
import com.kelp.crm.entity.ECustomer;
import com.kelp.crm.service.ECustomerService;
import com.opensymphony.oscache.util.StringUtil;
@@ -14,6 +17,9 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class BuyController {
@Autowired
private IdWorker idWorker;
private final String prefix = "/business/buy";
protected String RESULT = "result";
@@ -24,9 +30,11 @@ public class BuyController {
@Autowired
private ECustomerService customerService;
@Autowired
protected RedisBean redisBean;
@PostMapping(path = {prefix + "/{id}"})
public ModelMap index(@PathVariable("id") String id, Buy buy) {
@PostMapping(path = {prefix + "/{type}"})
public ModelMap index(@PathVariable("type") String type, Buy buy) {
ModelMap modelMap = new ModelMap();
ECustomer eCustomer = new ECustomer();
@@ -53,6 +61,18 @@ public class BuyController {
modelMap.put(RESULT, false);
return modelMap;
}
String timestamp = buy.getTimestamp();
String captcha = buy.getCaptcha();
if(!StringUtil.isEmpty(timestamp)){
String captcha_ = redisBean.hget(Constants.KAPTCHA_SESSION_KEY, timestamp);
if(captcha_ == null || !captcha_.equals(captcha)) {
modelMap.put(RESULT, false);
modelMap.put(MESSAGE, "验证码不正确或已过期!");
return modelMap;
}
}
eCustomer.setTelephone(telephone);
eCustomer.setEffctiveTime(System.currentTimeMillis());
eCustomer.setExpiredTime(System.currentTimeMillis());
@@ -67,7 +87,8 @@ public class BuyController {
} else {
buy.setCustomerId(customer.getId());
}
buy.setType(id);
buy.setType(type);
buy.setId(idWorker.nextId());
buyDao.add(buy);
modelMap.put(RESULT, true);

View File

@@ -95,7 +95,7 @@ public class EMAccountController extends BaseController {
return modelMap;
}
account.setPassword(Md5Utils.hash("c1234567"));
account.setPassword(Md5Utils.hash("Yxt@67508182"));
accountService.add4m(account);
modelMap.put(RESULT, true);
@@ -103,6 +103,11 @@ public class EMAccountController extends BaseController {
return modelMap;
}
public static void main(String[] args) {
String pa = Md5Utils.hash("Yxt@67508182");
System.out.println(pa);
}
@RequestMapping("/update")
public @ResponseBody ModelMap update(HttpServletRequest request, EAccount account) {

View File

@@ -75,7 +75,7 @@ public class PAccountController extends BaseController {
}
account.setId(null);
account.setPassword(Md5Utils.hash("k1234567"));
account.setPassword(Md5Utils.hash("Yxt@67508182"));
accountService.add(account);
modelMap.put(RESULT, true);

View File

@@ -13,16 +13,24 @@ layui.use([ 'carousel', 'form' ], function() {
timestamp = (new Date()).valueOf();
var type = system_config?.captchaType || "math"; // 默认 math
var url = basePath + "/captcha/captchaImage?type=" + type + "&timestamp=" + timestamp;
console.log("点击验证码啦啦啦啦啦")
$(".imgcode").attr("src", url);
$(".imgcode").data("ts", timestamp); // 👈 存一下
}
// 页面加载时刷新验证码
refreshCaptcha(); // ✅ 页面加载手动刷新
$('#telephone').focus();
// 点击验证码图片刷新
$('.imgcode').off('click').on('click', refreshCaptcha); // ✅ 点击后刷新
// 事件委托 + 每次点击时都能绑定
$(document).on('click', '.imgcode', function () {
console.log('验证码点击了');
var timestamp = Date.now();
var type = system_config?.captchaType || "math";
var url = basePath + "/captcha/captchaImage?type=" + type + "&timestamp=" + timestamp;
$(this).attr("src", url);
$(".imgcode").data("ts", timestamp); // 👈 存一下
});
// 监听提交
form.on('submit(login_)', function(data) {
@@ -51,7 +59,7 @@ layui.use([ 'carousel', 'form' ], function() {
"telephone":telephone,
"password":MD5(password),
"captcha":captcha,
"timestamp":timestamp
"timestamp":$(".imgcode").data("ts")
},
type : 'post',
dataType : 'json',

View File

@@ -12,7 +12,7 @@ public class RichFreeMarkerView extends FreeMarkerView {
protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request)
throws Exception {
String baseUrl = "http://aos.yyundong.com" + request.getContextPath();
String baseUrl = "http://netsafe.yxtsoft.com" + request.getContextPath();
// String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
model.put("contextPath", request.getContextPath());

View File

@@ -35,7 +35,6 @@ public class InterceptorConfig extends WebMvcConfigurationSupport {
public EInterceptor eInterceptor() {
return new EInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
@@ -45,6 +44,7 @@ public class InterceptorConfig extends WebMvcConfigurationSupport {
registry.addInterceptor(pInterceptor()).addPathPatterns("/plat/**").excludePathPatterns("/plat/index","/plat/login");
registry.addInterceptor(eInterceptor()).addPathPatterns("/crm/**").excludePathPatterns("/crm/index","/crm/login");
}
/**

View File

@@ -24,6 +24,27 @@ public class Buy extends BaseEntity {
private String fuwu;
@Transient
private String captcha;
@Transient
private String timestamp;
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getFuwu() {
return fuwu;
}

View File

@@ -4,6 +4,7 @@ import java.util.List;
import com.kelp.base.Page;
import com.kelp.crm.entity.ECustomer;
import com.kelp.crm.entity.Enterprise;
public interface ECustomerService {
@@ -23,5 +24,5 @@ public interface ECustomerService {
String state);
public Page<ECustomer> getPage4NoVisit(int pageNumber, int pageSize, String startDate, String endDate);
public ECustomer getByPhone(String phone);
}

View File

@@ -26,4 +26,5 @@ public interface EnterpriseService {
public List<Enterprise> listTop(Long pId);
public List<Enterprise> listdsub(String pId);
public List<Enterprise> listdsub(String pId ,String type);
public Enterprise getByPhone(String phone);
}

View File

@@ -81,6 +81,11 @@ public class ECustomerServiceImpl implements ECustomerService {
return page;
}
@Override
public ECustomer getByPhone(String phone) {
return customerDao.get("telePhone",phone);
}
@Override
public List<ECustomer> getAll(String state) {
return customerDao.getAll(state);

View File

@@ -92,5 +92,10 @@ public class EnterpriseServiceImpl implements EnterpriseService {
public List<Enterprise> listdsub(String pId,String type) {
return enterpriseDao.listdsub(Long.valueOf(pId),type);
}
@Override
public Enterprise getByPhone(String phone) {
return enterpriseDao.get("phone",phone);
}
}