用户登录的时候,校验用户是否已经注册,以及未注册的注册接口
This commit is contained in:
parent
8498005f11
commit
f1b54cd54b
|
|
@ -4,14 +4,15 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ghy.common.config.WxConfig;
|
import com.ghy.common.config.WxConfig;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
import com.ghy.common.utils.ExceptionUtil;
|
||||||
|
import com.ghy.common.utils.StringUtils;
|
||||||
import com.ghy.common.utils.WxUtils;
|
import com.ghy.common.utils.WxUtils;
|
||||||
import com.ghy.common.utils.http.HttpUtils;
|
import com.ghy.common.utils.http.HttpUtils;
|
||||||
|
import com.ghy.customer.domain.Customer;
|
||||||
|
import com.ghy.customer.service.CustomerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -31,6 +32,39 @@ public class WxController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private WxConfig wxConfig;
|
private WxConfig wxConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerService customerService;
|
||||||
|
|
||||||
|
@PostMapping("/addUser")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult addUser(Customer customer){
|
||||||
|
try {
|
||||||
|
int result = customerService.insertCustomer(customer);
|
||||||
|
if(result>0){
|
||||||
|
return AjaxResult.success("新增用户成功");
|
||||||
|
}else {
|
||||||
|
return AjaxResult.warn("新增用户失败!");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(ExceptionUtil.getExceptionMessage(e));
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getUserInfo")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult getUserInfo(@RequestBody Customer customer){
|
||||||
|
try {
|
||||||
|
Customer result = customerService.selectByOpenId(customer);
|
||||||
|
if(StringUtils.isNull(result)){
|
||||||
|
return AjaxResult.error("用户不存在");
|
||||||
|
}
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}catch (Exception e){
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/token")
|
@GetMapping("/token")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String token(String timestamp, String nonce, String signature, String echostr) throws IOException {
|
public String token(String timestamp, String nonce, String signature, String echostr) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface CustomerService {
|
public interface CustomerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param customer 查询信息
|
||||||
|
* @return 消费者信息
|
||||||
|
*/
|
||||||
|
Customer selectByOpenId(Customer customer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param customer 消费者筛选条件
|
* @param customer 消费者筛选条件
|
||||||
* @return 消费者列表
|
* @return 消费者列表
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ghy.customer.service.impl;
|
||||||
|
|
||||||
import com.ghy.common.core.text.Convert;
|
import com.ghy.common.core.text.Convert;
|
||||||
import com.ghy.common.exception.ServiceException;
|
import com.ghy.common.exception.ServiceException;
|
||||||
|
import com.ghy.common.utils.StringUtils;
|
||||||
import com.ghy.customer.domain.Customer;
|
import com.ghy.customer.domain.Customer;
|
||||||
import com.ghy.customer.mapper.CustomerMapper;
|
import com.ghy.customer.mapper.CustomerMapper;
|
||||||
import com.ghy.customer.service.CustomerService;
|
import com.ghy.customer.service.CustomerService;
|
||||||
|
|
@ -30,6 +31,16 @@ public class CustomerServiceImpl implements CustomerService {
|
||||||
return customerMapper.getCustomerList(customer);
|
return customerMapper.getCustomerList(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Customer selectByOpenId(Customer customer) {
|
||||||
|
List<Customer> list = customerMapper.getCustomerList(customer);
|
||||||
|
if(StringUtils.isNotEmpty(list)){
|
||||||
|
return list.get(0);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteByIds(String ids) {
|
public int deleteByIds(String ids) {
|
||||||
Long [] customerIds = Convert.toLongArray(ids);
|
Long [] customerIds = Convert.toLongArray(ids);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@
|
||||||
|
|
||||||
<select id="getCustomerList" resultMap="CustomerResult">
|
<select id="getCustomerList" resultMap="CustomerResult">
|
||||||
<include refid="selectCustomer" />
|
<include refid="selectCustomer" />
|
||||||
|
<where>
|
||||||
|
<if test="openId != null and openId != ''">
|
||||||
|
AND open_id = #{openId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteByIds">
|
<delete id="deleteByIds">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue