Authored by LiQZ

Merge branch 'channel' of http://git.yoho.cn/yoho30/yohobuy-union into channel

package com.yoho.channel.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by yoho on 2017/2/15.
*/
public class ChannelGroupRest {
static Logger log = LoggerFactory.getLogger(ChannelGroupRest.class);
}
package com.yoho.channel.service.impl;
import com.yoho.channel.service.ChannelGroupService;
import com.yoho.unions.dal.IChannelGroupDAO;
import com.yoho.unions.dal.model.ChannelGroup;
import org.springframework.beans.factory.annotation.Autowired;
import sun.rmi.transport.Channel;
import java.util.List;
/**
* Created by yoho on 2017/2/15.
*/
public class ChannelGroupServiceImpl implements ChannelGroupService{
@Autowired
private IChannelGroupDAO channelGroupDAO;
@Override
public List<ChannelGroup> getChannelGroupList(ChannelGroup channelGroup) {
return null;
}
}
package com.yoho.unions.channel.restapi;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.dal.model.ChannelGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by yoho on 2017/2/15.
*/
@Controller
@RequestMapping("/channel")
public class ChannelGroupRest {
static Logger logger = LoggerFactory.getLogger(ChannelGroupRest.class);
@Autowired
private ChannelGroupService channelGroupService;
@RequestMapping("/queryChannelGroupList")
@ResponseBody
public ApiResponse queryChannelGroupList(@RequestBody ChannelGroupRequestBO channelGroupRequestBO) {
logger.info("enter queryChannelGroupList. param channelGroupRequestBO={}", channelGroupRequestBO);
try {
PageChannelGroupRspBO pageChannelGroupRspBO = channelGroupService.queryChannelGroupList(channelGroupRequestBO);
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(pageChannelGroupRspBO).build();
} catch (Exception e) {
logger.warn("queryChannelGroupList occurs Exception e {}",e.getMessage());
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
}
... ...
package com.yoho.channel.service;
package com.yoho.unions.channel.service;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.dal.model.ChannelGroup;
import java.util.List;
... ... @@ -8,6 +10,6 @@ import java.util.List;
* Created by yoho on 2017/2/15.
*/
public interface ChannelGroupService {
public List<ChannelGroup> getChannelGroupList(ChannelGroup channelGroup);
PageChannelGroupRspBO queryChannelGroupList(ChannelGroupRequestBO channelGroupRequestBO);
}
... ...
package com.yoho.unions.channel.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.response.ChannelGroupRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.dal.IChannelGroupDAO;
import com.yoho.unions.dal.model.ChannelGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yoho on 2017/2/15.
*/
@Service
public class ChannelGroupServiceImpl implements ChannelGroupService {
static Logger logger = LoggerFactory.getLogger(ChannelGroupService.class);
@Autowired
private IChannelGroupDAO channelGroupDAO;
@Override
public PageChannelGroupRspBO queryChannelGroupList(ChannelGroupRequestBO channelGroupRequestBO) {
logger.info("enter queryChannelGroupList. param channelGroupRequestBO={}", channelGroupRequestBO);
// (1)参数校验
if (null == channelGroupRequestBO) {
throw new ServiceException(ServiceError.MISSING_PARAMETER);
}
// (2)查询:总数和列表
int total = channelGroupDAO.selectListCountByParam(channelGroupRequestBO);
List<ChannelGroup> channelGroupList = channelGroupDAO.selectListByParam(channelGroupRequestBO);
List<ChannelGroupRspBO> channelGroupBOList = toRspBOList(channelGroupList);
// (3)返回
PageChannelGroupRspBO pageChannelGroupRspBO = new PageChannelGroupRspBO();
pageChannelGroupRspBO.setList(channelGroupBOList);
pageChannelGroupRspBO.setTotal(total);
pageChannelGroupRspBO.setPage(channelGroupRequestBO.getPage());
// pageChannelGroupRspBO.setSize(channelGroupRequestBO.getSize());
return pageChannelGroupRspBO;
}
private List<ChannelGroupRspBO> toRspBOList(List<ChannelGroup> channelGroupList) {
logger.info("enter toRspBOList. param channelGroupList={}", channelGroupList);
List<ChannelGroupRspBO> list = new ArrayList<>();
if(CollectionUtils.isEmpty(channelGroupList)){
return list;
}
for(int i=0;i<channelGroupList.size();i++){
ChannelGroupRspBO channelGroupRspBO = new ChannelGroupRspBO();
BeanUtils.copyProperties(channelGroupList.get(i),channelGroupRspBO);
channelGroupRspBO.setCreateTime(DateUtil.long2DateStr(channelGroupList.get(i).getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
list.add(channelGroupRspBO);
}
return list;
}
}
... ...
... ... @@ -33,6 +33,7 @@
<value>/tencentMkt/TencentMktController/sendSms</value>
<value>/tencentMkt/TencentMktController/getActivityInfo</value>
<value>/tencentMkt/TencentMktController/validRegCodeAndSendCode</value>
<value>/channel/queryChannelGroupList</value>
</list>
</property>
<property name="excludeMethods">
... ...
package com.yoho.unions.dal;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.unions.dal.model.ChannelGroup;
import java.util.List;
... ... @@ -17,5 +18,7 @@ public interface IChannelGroupDAO {
int updateByPrimaryKey(ChannelGroup record);
List<ChannelGroup> getChannelGroupList(ChannelGroup channelGroup);
int selectListCountByParam(ChannelGroupRequestBO channelGroupRequestBO);
List<ChannelGroup> selectListByParam(ChannelGroupRequestBO channelGroupRequestBO);
}
\ No newline at end of file
... ...
... ... @@ -14,7 +14,7 @@
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, name, group_number, create_time, create_user, sms_number, send_time, send_user,
id, name ,create_time, create_user, sms_number, send_time, send_user,
content, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
... ... @@ -150,28 +150,63 @@
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getChannelGroupList" resultMap="BaseResultMap" parameterType="com.yoho.unions.dal.model.ChannelGroup" >
select
<include refid="Base_Column_List" />
from channel_group
where 1=1
<if test="channelGroup.name != null" >
and name = #{channelGroup.name,jdbcType=VARCHAR},
</if>
<if test="channelGroup.createTime != null" >
and create_time>=#{channelGroup.createTime,jdbcType=INTEGER} and create_time &lt;=#{channelGroup.createTime,jdbcType=INTEGER}
</if>
<if test="channelGroup.createUser != null" >
create_user = #{channelGroup.createUser,jdbcType=INTEGER},
</if>
<if test="channelGroup.smsNumber != null" >
sms_number = #{channelGroup.smsNumber,jdbcType=INTEGER},
</if>
<if test="channelGroup.sendTime != null" >
send_time >= #{channelGroup.sendTime,jdbcType=INTEGER} and send_time &lt; #{channelGroup.sendTime,jdbcType=INTEGER}
</if>
<if test="channelGroup.sendUser != null" >
send_user = #{channelGroup.sendUser,jdbcType=INTEGER},
</if>
<select id="selectListCountByParam" resultType="java.lang.Integer" parameterType="com.yoho.service.model.union.request.ChannelGroupRequestBO" >
select count(*) from channel_group
<where>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR}
</if>
<if test="createTimeBegin != null" >
and create_time>=#{createTimeBegin,jdbcType=INTEGER}
</if>
<if test="createTimeEnd != null" >
and create_time &lt;=#{createTimeEnd,jdbcType=INTEGER}
</if>
<if test="createUser != null" >
and create_user = #{createUser,jdbcType=INTEGER}
</if>
<if test="smsNumber != null" >
and sms_number = #{smsNumber,jdbcType=INTEGER}
</if>
<if test="sendTimeBegin != null" >
and send_time >= #{sendTimeBegin,jdbcType=INTEGER}
</if>
<if test="sendTimeEnd != null" >
and send_time &lt; #{sendTimeEnd,jdbcType=INTEGER}
</if>
<if test="sendUser != null" >
and send_user = #{sendUser,jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectListByParam" resultMap="BaseResultMap" parameterType="com.yoho.service.model.union.request.ChannelGroupRequestBO" >
select <include refid="Base_Column_List" /> from channel_group
<where>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR}
</if>
<if test="createTimeBegin != null" >
and create_time>=#{createTimeBegin,jdbcType=INTEGER}
</if>
<if test="createTimeEnd != null" >
and create_time &lt;=#{createTimeEnd,jdbcType=INTEGER}
</if>
<if test="createUser != null" >
and create_user = #{createUser,jdbcType=INTEGER}
</if>
<if test="smsNumber != null" >
and sms_number = #{smsNumber,jdbcType=INTEGER}
</if>
<if test="sendTimeBegin != null" >
and send_time >= #{sendTimeBegin,jdbcType=INTEGER}
</if>
<if test="sendTimeEnd != null" >
and send_time &lt; #{sendTimeEnd,jdbcType=INTEGER}
</if>
<if test="sendUser != null" >
and send_user = #{sendUser,jdbcType=INTEGER}
</if>
</where>
ORDER BY create_time DESC limit #{start,jdbcType=INTEGER}, #{size,jdbcType=INTEGER}
</select>
</mapper>
... ...
... ... @@ -42,6 +42,11 @@
<artifactId>yoho-unions-common</artifactId>
<version>${project-version}</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.unions</groupId>
<artifactId>yoho-unions-channel</artifactId>
<version>${project-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
... ...
... ... @@ -32,6 +32,10 @@
<artifactId>yoho-unions-common</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.dsf.unions</groupId>
<artifactId>yoho-unions-channel</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.0</version>
... ...
... ... @@ -3,13 +3,13 @@ cache.servers.memcached.address=192.168.102.211:11211
####暂时不使用,待到订单上线的时候恢复使用#########
#MQ
rabbit.mq.host=192.168.102.217
rabbit.mq.host=192.168.102.211
rabbit.mq.port=5672
rabbit.mq.username=yoho
rabbit.mq.password=yoho
#rabbit.mq.virtualHost=/yoho
rabbit_host=192.168.102.217:5672
rabbit_host=192.168.102.211:5672
rabbit_user=yoho
rabbit_password =yoho
... ... @@ -36,11 +36,11 @@ redis.proxy.database=1
########## common rabbitmq ##########
#aws
rabbit_common_aws=192.168.102.217:5672
rabbit_common_aws=192.168.102.211:5672
rabbit_common_aws_user=yoho
rabbit_common_aws_password=yoho
#qq
rabbit_common_qq=192.168.102.203:5672
rabbit_common_qq=192.168.102.211:5672
rabbit_common_qq_user=yoho
rabbit_common_qq_password=yoho
##########common rabbitmq ##########
... ...
... ... @@ -42,5 +42,10 @@ datasources:
- com.yoho.unions.dal.IUnionTypeMatchDAO
- com.yoho.unions.dal.ITencentMktActivityDAO
- com.yoho.unions.dal.ITencentMktCouponHistoryDAO
- com.yoho.unions.dal.IChannelGroupDAO
- com.yoho.unions.dal.IChannelUserDAO
- com.yoho.unions.dal.IChannelSmsDetailDAO
- com.yoho.unions.dal.IChannelGroupConditionDAO
- com.yoho.unions.dal.IChannelGroupBatchDAO
readOnlyInSlave: true
\ No newline at end of file
... ...