Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
014a9ae814
|
|
@ -91,6 +91,11 @@
|
|||
<artifactId>ghy-custom</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ghy</groupId>
|
||||
<artifactId>ghy-message</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ghy</groupId>
|
||||
<artifactId>ghy-worker</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.ghy.web.controller.customer;
|
||||
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.customer.domain.Customer;
|
||||
import com.ghy.customer.service.CustomerService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
|
@ -50,5 +52,17 @@ public class CustomerController extends BaseController {
|
|||
return prefix + "/resetPwd";
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
public AjaxResult updateCustomer(@RequestBody Customer customer){
|
||||
try {
|
||||
customerService.updateCustomer(customer);
|
||||
return AjaxResult.success("更新消费者手机号成功");
|
||||
}catch (Exception e){
|
||||
ExceptionUtil.getExceptionMessage(e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.ghy.common.config.WxConfig;
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.enums.UserPhoneEnum;
|
||||
import com.ghy.common.exception.ServiceException;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.common.utils.WxUtils;
|
||||
import com.ghy.common.utils.http.HttpUtils;
|
||||
import com.ghy.customer.domain.Customer;
|
||||
|
|
@ -125,7 +123,7 @@ public class WxController extends BaseController {
|
|||
}else {
|
||||
accessToken = getAccessToken(sysDeptConfig.getServWxAppId(), sysDeptConfig.getServWxSecret());
|
||||
}
|
||||
return AjaxResult.success(getPhoneNumber(code, accessToken));
|
||||
return AjaxResult.success("获取手机号成功", getPhoneNumber(code, accessToken));
|
||||
}catch (Exception e){
|
||||
logger.error(ExceptionUtil.getExceptionMessage(e));
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
|
@ -162,22 +160,17 @@ public class WxController extends BaseController {
|
|||
private static String getAccessToken(String appId, String appSecret){
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+ appId +"&secret=" + appSecret;
|
||||
String result = HttpUtils.sendGet(url);
|
||||
String code = JSONObject.parseObject(result).getString("errcode");
|
||||
if("0".equals(code)){
|
||||
return JSONObject.parseObject(result).getString("access_token");
|
||||
}else {
|
||||
throw new ServiceException("获取授权码异常");
|
||||
}
|
||||
return JSONObject.parseObject(result).getString("access_token");
|
||||
}
|
||||
|
||||
private static String getPhoneNumber(String code, String accessToken){
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("code", code);
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
|
||||
String result = HttpUtils.sendSSLPost(url, params.toString());
|
||||
String errCode = JSONObject.parseObject(result).getString("errCode");
|
||||
String result = HttpUtils.sendPost(url, params.toString());
|
||||
String errCode = JSONObject.parseObject(result).getString("errcode");
|
||||
if("0".equals(errCode)){
|
||||
return JSONObject.parseObject(result).getJSONObject("phoneInfo").getString("purePhoneNumber");
|
||||
return JSONObject.parseObject(result).getJSONObject("phone_info").getString("purePhoneNumber");
|
||||
}else {
|
||||
throw new ServiceException("获取手机号码异常");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package com.ghy.web.controller.worker;
|
||||
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.worker.domain.Worker;
|
||||
import com.ghy.worker.service.WorkerService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -43,4 +42,16 @@ public class WorkerController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
public AjaxResult updateWorker(@RequestBody Worker worker){
|
||||
try {
|
||||
workerService.updateWorker(worker);
|
||||
return AjaxResult.success("");
|
||||
}catch (Exception e){
|
||||
logger.error(ExceptionUtil.getExceptionMessage(e));
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
package com.ghy.common.enums;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public enum UserPhoneEnum {
|
||||
|
||||
|
||||
CUSTOMER_PHONE("customer"){
|
||||
@Override
|
||||
public Object getPhone(Long customerId) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
WORKER_PHONE("worker"){
|
||||
@Override
|
||||
public Object getPhone(Long workerId) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
private String code;
|
||||
|
||||
UserPhoneEnum(String code){
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public abstract Object getPhone(Long userId);
|
||||
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
</insert>
|
||||
|
||||
<update id="updateCustomer" parameterType="com.ghy.customer.domain.Customer">
|
||||
update costomer
|
||||
update customer
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="account != null and account != ''">account = #{account},</if>
|
||||
|
|
|
|||
|
|
@ -279,6 +279,8 @@ public class ShiroConfig
|
|||
filterChainDefinitionMap.put("/wx/**", "anon");
|
||||
filterChainDefinitionMap.put("/pay/**", "anon");
|
||||
filterChainDefinitionMap.put("/order/**", "anon");
|
||||
filterChainDefinitionMap.put("/worker/**", "anon");
|
||||
filterChainDefinitionMap.put("/customer/**", "anon");
|
||||
filterChainDefinitionMap.put("/goods/**", "anon");
|
||||
filterChainDefinitionMap.put("/tool/**", "anon");
|
||||
filterChainDefinitionMap.put("/adapay/**", "anon");
|
||||
|
|
|
|||
|
|
@ -18,4 +18,10 @@ public interface WorkerMapper {
|
|||
*/
|
||||
int insertWorker(Worker worker);
|
||||
|
||||
/**
|
||||
* @param worker 师傅信息
|
||||
* @return 更新成功条数
|
||||
*/
|
||||
int updateWorker(Worker worker);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,10 @@ public interface WorkerService {
|
|||
*/
|
||||
int insertWorker(Worker worker);
|
||||
|
||||
/**
|
||||
* @param worker 师傅信息
|
||||
* @return 更新成功条数
|
||||
*/
|
||||
int updateWorker(Worker worker);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,8 @@ public class WorkerServiceImpl implements WorkerService {
|
|||
return workerMapper.insertWorker(worker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateWorker(Worker worker) {
|
||||
return workerMapper.updateWorker(worker);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,12 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
<update id="updateWorker" >
|
||||
update worker
|
||||
<set>
|
||||
<if test="account != null and account != ''"> account = #{account},</if>
|
||||
<if test="phone != null and phone != ''"> phone = #{phone},</if>
|
||||
</set>
|
||||
where worker_id = #{workerId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue