add 登出、修改密码、商户进件、商户列表、商户详情

master
luoyang 6 years ago
parent cff2f0d16d
commit f9b4088561

@ -1,5 +1,8 @@
package au.com.royalpay.payment.manage.appclient.core;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
@ -8,6 +11,20 @@ public interface ManageAppService {
void updateDevToken(JSONObject device, String devToken);
void updateDevTokenStatus(String devId, int status);
JSONObject getDevTokenByDevId(String dev_id);
void sign_out(JSONObject device);
void changeAccountPassword(JSONObject device, ChangePwdBean change, String manager_id);
List<JSONObject> getReferrerList(JSONObject device);
JSONObject registerClient(JSONObject device, ClientRegisterInfo registery);
List<JSONObject> listPartners(JSONObject device, PartnerQuery query);
JSONObject clientDetail(JSONObject device, String clientMoniker);
}

@ -1,11 +1,22 @@
package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
import au.com.royalpay.payment.manage.mappers.system.ManageDeviceTokenMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -18,16 +29,85 @@ public class ManageAppServiceImp implements ManageAppService {
private ManageDeviceSupport manageDeviceSupport;
@Resource
private OrgMapper orgMapper;
@Resource
private ManagerMapper managerMapper;
@Resource
private ClientManager clientManager;
@Resource
private SignInAccountService signInAccountService;
@Resource
private ManageDeviceTokenMapper manageDeviceTokenMapper;
@Override
public void updateDevToken(JSONObject device, String devToken) {
manageDeviceSupport.updateDeviceMessageToken(device, devToken);
}
@Override
public void sign_out(JSONObject device) {
String clientType = device.getString("client_type");
DeviceRegister register = manageDeviceSupport.findRegister(clientType);
register.manageSignout(device);
}
@Override
public void changeAccountPassword(JSONObject device, ChangePwdBean change, String manager_id) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
// JSONObject client = signInAccountService.getClient(account_id);
if (!manager_id.equals(device.getString("manager_id"))) {
throw new ForbiddenException("You have no permission");
}
signInAccountService.changeManagerPassword(device, change);
updateDevTokenStatus(device.getString("dev_id"), 0);
}
@Override
public List<JSONObject> getReferrerList(JSONObject device) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
return orgMapper.listOrgs(1,new PageBounds());
}
@Override
public JSONObject registerClient(JSONObject device, ClientRegisterInfo registery) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
return clientManager.registerClient(null, registery, manager);
}
@Override
public List<JSONObject> listPartners(JSONObject device, PartnerQuery query) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
return clientManager.listPartners( manager, query);
}
@Override
public JSONObject clientDetail(JSONObject device, String clientMoniker) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
return clientManager.clientDetail(manager, clientMoniker);
}
@Override
public void updateDevTokenStatus(String devId, int status) {
JSONObject devTokenObj = getDevTokenByDevId(devId);
if (devTokenObj != null) {
devTokenObj.put("is_valid", status);
manageDeviceTokenMapper.update(devTokenObj);
}
}
@Override
@Cacheable(value = ":dev_message_token:", key = "#dev_id")
public JSONObject getDevTokenByDevId(String dev_id) {
return manageDeviceTokenMapper.findByDevId(dev_id);
}
}

@ -1,16 +1,26 @@
package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/api/v1.0/manage/app")
public class ManageAppController {
@ -18,14 +28,53 @@ public class ManageAppController {
@Resource
private ManageAppService manageAppService;
@Resource
private AttachmentClient attachmentClient;
@RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, @RequestBody JSONObject token) {
manageAppService.updateDevToken(device, token.getString("devToken"));
}
@RequestMapping(value = "/sign_out", method = RequestMethod.PUT)
public void signOut(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device) {
manageAppService.sign_out(device);
}
@RequestMapping(value = "/manager_password/{manager_id}", method = RequestMethod.PUT)
public void changePassword(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, @PathVariable String manager_id,
@RequestBody @Valid ChangePwdBean change, Errors errors) {
HttpUtils.handleValidErrors(errors);
manageAppService.changeAccountPassword(device, change, manager_id);
}
@RequestMapping(value = "/referrer", method = RequestMethod.GET)
public List<JSONObject> getReferrerList(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, @RequestBody JSONObject token) {
return manageAppService.getReferrerList(device);
return manageAppService.getReferrerList(device);
}
@RequestMapping(value = "/attachment/files", method = RequestMethod.POST)
public JSONObject uploadImage(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, @RequestParam MultipartFile file) throws Exception {
return attachmentClient.uploadFile(file, false);
}
@RequestMapping(value = "/merchant/register", method = RequestMethod.POST)
public JSONObject registerPartner(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, @RequestBody @Valid ClientRegisterInfo registery,
Errors errors){
HttpUtils.handleValidErrors(errors);
return manageAppService.registerClient(device, registery);
}
@RequestMapping(value = "/merchants", method = RequestMethod.GET)
public List<JSONObject> listPartners(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, PartnerQuery query) {
return manageAppService.listPartners(device, query);
}
@RequestMapping(value = "/merchant/{clientMoniker}/detail", method = RequestMethod.GET)
public JSONObject getClientByMoniker(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device) {
return manageAppService.clientDetail(device, clientMoniker);
}
}

@ -0,0 +1,25 @@
package au.com.royalpay.payment.manage.mappers.system;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by yixian on 2016-09-12.
*/
@AutoMapper(tablename = "sys_manage_devices_token", pkName = "dev_token_id")
public interface ManageDeviceTokenMapper {
JSONObject findByDevId(@Param("dev_id") String devDevId);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject devInfo);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject devTokenInfo);
}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.ManageDeviceTokenMapper">
<select id="findByDevId" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM sys_manage_devices_token where dev_id=#{dev_id} limit 1
</select>
</mapper>
Loading…
Cancel
Save