Explorar o código

短信记录保存BUG

suxiaoyang %!s(int64=6) %!d(string=hai) anos
pai
achega
3b74efe6fc

+ 6 - 6
common/common-entity/src/main/java/com/yihu/jw/entity/base/sms/SmsDO.java

@ -21,7 +21,7 @@ public class SmsDO extends UuidIdentityEntity {
	//请求的ip地址
	private String requestIp;
	//短信接收号码
	private String to;
	private String mobile;
	//短信内容
	private String content;
	//过期时间
@ -58,13 +58,13 @@ public class SmsDO extends UuidIdentityEntity {
		this.requestIp = requestIp;
	}
	@Column(name = "to", nullable = false)
	public String getTo() {
		return to;
	@Column(name = "mobile", nullable = false)
	public String getMobile() {
		return mobile;
	}
	public void setTo(String to) {
		this.to = to;
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	@Column(name = "content", nullable = false)

+ 7 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -137,6 +137,13 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/sms_template";
    }
    /**
     * 短信模板
     */
    public static class Sms extends Basic {
        public static final String PREFIX  = "/sms";
    }
    /**
     * 服务包
     */

+ 6 - 5
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/SmsVO.java

@ -27,7 +27,7 @@ public class SmsVO extends UuidIdentityVO {
    private String requestIp;
    //短信接收号码
    @ApiModelProperty(value = "短信接收号码", example = "18888888888")
    private String to;
    private String mobile;
    //短信内容
    @ApiModelProperty(value = "短信内容", example = "【i健康综合管理平台】您使用的是i健康综合管理平台短信模板,您的验证码是826612,请于10分钟内正确输入!")
    private String content;
@ -35,6 +35,7 @@ public class SmsVO extends UuidIdentityVO {
    @ApiModelProperty(value = "过期时间", example = "2018-09-03 15:34:34")
    private Date deadline;
    //验证码
    @ApiModelProperty(value = "验证码", example = "651187")
    private String captcha;
    @ApiModelProperty(value = "标签", example = "login")
    private SmsTemplateDO.Type type;
@ -63,12 +64,12 @@ public class SmsVO extends UuidIdentityVO {
        this.requestIp = requestIp;
    }
    public String getTo() {
        return to;
    public String getMobile() {
        return mobile;
    }
    public void setTo(String to) {
        this.to = to;
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getContent() {

+ 96 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sms/SmsEndpoint.java

@ -0,0 +1,96 @@
package com.yihu.jw.base.endpoint.sms;
import com.yihu.jw.base.service.sms.SmsService;
import com.yihu.jw.entity.base.sms.SmsDO;
import com.yihu.jw.restmodel.base.sms.SmsVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Endpoint - 短信记录
 * Created by progr1mmer on 2018/9/6.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.Sms.PREFIX)
@Api(value = "短信记录管理", description = "短信记录管理服务接口", tags = {"wlyy基础服务 - 短信记录管理服务接口"})
public class SmsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SmsService smsService;
    @PostMapping(value = BaseRequestMapping.Sms.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<SmsVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SmsDO smsDO = toEntity(jsonData, SmsDO.class);
        smsDO = smsService.save(smsDO);
        return success(smsDO, SmsVO.class);
    }
    @PostMapping(value = BaseRequestMapping.Sms.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        smsService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.Sms.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<SmsVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SmsDO smsDO = toEntity(jsonData, SmsDO.class);
        if (null == smsDO.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        smsDO = smsService.save(smsDO);
        return success(smsDO, SmsVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Sms.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SmsVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<SmsDO> smsDOS = smsService.search(fields, filters, sorts, page, size);
        int count = (int)smsService.getCount(filters);
        return success(smsDOS, count, page, size, SmsVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Sms.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SmsVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<SmsDO> smsDOS = smsService.search(fields, filters, sorts);
        return success(smsDOS, SmsVO.class);
    }
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sms/SmsGatewayEndpoint.java

@ -40,7 +40,7 @@ public class SmsGatewayEndpoint extends EnvelopRestEndpoint {
            @RequestBody String jsonData) throws Exception {
        SmsGatewayDO smsGatewayDO = toEntity(jsonData, SmsGatewayDO.class);
        smsGatewayDO = smsGatewayService.save(smsGatewayDO);
        return success(convertToModel(smsGatewayDO, SmsGatewayVO.class));
        return success(smsGatewayDO, SmsGatewayVO.class);
    }
    @PostMapping(value = BaseRequestMapping.SmsGateway.DELETE)
@ -62,7 +62,7 @@ public class SmsGatewayEndpoint extends EnvelopRestEndpoint {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        smsGatewayDO = smsGatewayService.save(smsGatewayDO);
        return success(convertToModel(smsGatewayDO, SmsGatewayVO.class));
        return success(smsGatewayDO, SmsGatewayVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SmsGateway.PAGE)

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sms/SmsTemplateEndpoint.java

@ -37,7 +37,7 @@ public class SmsTemplateEndpoint extends EnvelopRestEndpoint {
            @RequestBody String jsonData) throws Exception {
        SmsTemplateDO smsTemplateDO = toEntity(jsonData, SmsTemplateDO.class);
        smsTemplateDO = smsTemplateService.save(smsTemplateDO);
        return success(convertToModel(smsTemplateDO, SmsTemplateVO.class));
        return success(smsTemplateDO, SmsTemplateVO.class);
    }
    @PostMapping(value = BaseRequestMapping.SmsTemplate.DELETE)
@ -59,7 +59,7 @@ public class SmsTemplateEndpoint extends EnvelopRestEndpoint {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        smsTemplateDO = smsTemplateService.save(smsTemplateDO);
        return success(convertToModel(smsTemplateDO, SmsTemplateVO.class));
        return success(smsTemplateDO, SmsTemplateVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SmsTemplate.PAGE)

+ 8 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java

@ -91,13 +91,14 @@ public class SmsGatewayService extends BaseJpaService<SmsGatewayDO, SmsGatewayDa
        HttpResponse httpResponse = HttpUtils.doPost(smsGatewayDO.getRequestUrl(), objectMapper.readValue(rawCertificate, Map.class));
        if (httpResponse.isSuccessFlg()) {
            Map<String, Object> response = objectMapper.readValue(httpResponse.getContent(), Map.class);
            if (response.get(smsGatewayDO.getResponseCode()).equals(smsGatewayDO.getSuccessValue())) {
            String responseCode = String.valueOf(response.get(smsGatewayDO.getResponseCode()));
            if (responseCode.equals(smsGatewayDO.getSuccessValue())) {
                HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
                SmsDO smsDO = new SmsDO();
                smsDO.setClientId(clientId);
                smsDO.setSmsGatewayId(smsGatewayDO.getId());
                smsDO.setRequestIp(IPInfoUtils.getIPAddress(request));
                smsDO.setTo(to);
                smsDO.setMobile(to);
                smsDO.setContent(sendContent);
                smsDO.setDeadline(DateUtils.addMinutes(new Date(), smsGatewayDO.getExpireMin()));
                smsDO.setCaptcha(contentDatas[0]);
@ -111,4 +112,9 @@ public class SmsGatewayService extends BaseJpaService<SmsGatewayDO, SmsGatewayDa
        }
    }
    public static void main(String [] args) {
        Object obj = 1;
        System.out.println(obj.toString());
    }
}

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsService.java

@ -0,0 +1,15 @@
package com.yihu.jw.base.service.sms;
import com.yihu.jw.base.dao.sms.SmsDao;
import com.yihu.jw.entity.base.sms.SmsDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * Service - 短信记录
 * Created by progr1mmer on 2018/9/6.
 */
@Service
public class SmsService extends BaseJpaService<SmsDO, SmsDao>{
}

+ 1 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-base
    name: svr-base-sxy
  cloud:
    config:
      failFast: true