master
wangning 6 years ago
parent b7386bc81b
commit 3186110157

@ -23,7 +23,7 @@ public interface MailUnsubMapper {
void delete(@Param("id") Long id);
@AutoSql(type = SqlType.SELECT)
JSONObject getById(@Param("id") Long id);
JSONObject getOne(@Param("id") Long id,@Param("address") String address);
PageList<JSONObject> queryPageable(JSONObject params, PageBounds pagination);
}

@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
@ -203,9 +204,13 @@ public class MailServiceImp implements MailService {
if(client==null){
throw new NotFoundException("Merchant not Found");
}
JSONObject existRecord = mailUnsubMapper.getOne(null,client.getString("contact_email"));
if(existRecord!=null){
throw new BadRequestException("address has been added");
}
JSONObject record= new JSONObject();
record.put("id", IdUtil.getId());
record.put("address",client.getString("contact_mail"));
record.put("address",client.getString("contact_email"));
record.put("client_id",client.getIntValue("client_id"));
record.put("client_moniker",client.getString("client_moniker"));
mailUnsubMapper.save(record);

@ -23,23 +23,23 @@ public class MailController {
@Resource
private MailService mailService;
@RequestMapping(value = "/sub/{id}",method = RequestMethod.DELETE)
@RequestMapping(value = "/unsub/{id}",method = RequestMethod.DELETE)
// @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT})
public void removeSub(@PathVariable Long id) {
mailService.removeUnsub(id);
}
@RequestMapping(value = "/sub",method = RequestMethod.POST)
@RequestMapping(value = "/unsub",method = RequestMethod.POST)
// @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT})
public void removeSub(@RequestParam String client_moniker) {
mailService.addUnsub(client_moniker);
}
@RequestMapping(value = "/sub/query",method = RequestMethod.GET)
@RequestMapping(value = "/unsub/query",method = RequestMethod.GET)
// @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT})
public JSONObject list(@RequestParam String client_moniker,@RequestParam String address,@RequestParam int limit ,@RequestParam int page) {
public JSONObject list(@RequestParam(required = false) String client_moniker,@RequestParam(required = false) String address,@RequestParam(required = false,defaultValue = "10") int limit ,@RequestParam(required = false,defaultValue = "1") int page) {
JSONObject params = new JSONObject();
params.put("client_moinker",client_moniker);
params.put("client_moniker",client_moniker);
params.put("address",address);
return mailService.queryUnsubPageable(params,limit,page);
}

@ -1,17 +1,29 @@
<?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.MailUnsubMapper">
<select id="getOne" resultType="com.alibaba.fastjson.JSONObject">
select * from sys_mail_unsub
<where>
<if test="id!=null">
and id = #{id}
</if>
<if test="address != null">
and address = #{address}
</if>
</where>
</select>
<select id="queryPageable" resultType="com.alibaba.fastjson.JSONObject">
select * from sys_mail_unsub
<where>
<if test="client_moniker!=null">
client_moniker = #{client_moniker}
and client_moniker = #{client_moniker}
</if>
<if test="client_id != 0">
client_id = #{client_id}
<if test="client_id != null">
and client_id = #{client_id}
</if>
<if test="address != null">
address = #{address}
and address = #{address}
</if>
</where>
</select>

Loading…
Cancel
Save