1.ChannelListMapper.xml
c.channel_id,c.channel_name_cn,c.channel_name_en,c.activity_true,c.invoice_desc,c.fee_rate,c.channel_tel,c.channel_fax,c.channel_web,c.channel_email,
c.link_man,c.channel_province,c.channel_city,c.channel_area,c.channel_address,c.channel_true,c.consignee_true,c.deliver_true,c.property,c.create_date,
c.update_date,p.parent_owner_name
2.实体类:ChannelBaseVO.java,ChannelListVO.java
@Data可以直接建getset方法
package com.ysotek.wms.microservice.model.infrastructure.vo.tnb;
import com.ysotek.wms.microservice.model.infrastructure.vo.IChannelBaseVO;
import lombok.Data;
import java.util.Date;
/**
* Created by Cherry on 0013 13 十月.
*/
public @Data
class ChannelBaseVO implements IChannelBaseVO {
Long channelId;
String channelNameCn;
String parentOwnerName;
String channelTel;
String channelEmail;
String linkMan;
Date createDate;
}
package com.ysotek.wms.microservice.model.infrastructure.vo.tnb;
import com.ysotek.wms.microservice.model.infrastructure.vo.IChannelListVO;
import lombok.Data;
import java.util.Date;
/**
* Created by Cherry on 0012 12 十月.
*/
public @Data
class ChannelListVO implements IChannelListVO {
Long channelId;
String channelNameCn;
String channelNameEn;
String parentOwnerName;
boolean activityTrue;
String invoiceDesc;
Double feeRate;
String channelTel;
String channelFax;
String channelWeb;
String channelEmail;
String linkMan;
String channelProvince;
String channelCity;
String channelArea;
String channelAddress;
boolean channelTrue;
boolean consigneeTrue;
boolean deliverTrue;
String property;
Date createDate;
Date updateDate;
}
package com.ysotek.wms.microservice.model.infrastructure.vo;
/**
* Created by Cherry on 0013 13 十月.
*/
public interface IChannelBaseVO {
}
package com.ysotek.wms.microservice.model.infrastructure.vo;
/**
* Created by Cherry on 0012 12 十月.
*/
public interface IChannelListVO {
}
3.Dao数据层:ChannelListMapper.java
package com.ysotek.wms.microservice.infrastructure.mapper.impl.tnb;
import com.ysotek.wms.microservice.infrastructure.mapper.impl.IChannelListMapper;
import org.springframework.stereotype.Component;
/**
* Created by Cherry on 0012 12 十月.
*/
@Component("TnbChannelListMapper")
public interface ChannelListMapper extends IChannelListMapper {
}
package com.ysotek.wms.microservice.infrastructure.mapper.impl;
import java.util.List;
import java.util.Map;
/**
* Created by Cherry on 0012 12 十月.
*/
public interface IChannelListMapper {
List getList(Map map);
Long getCount(Map map);
List getChannelsList(Map map);
}
4.service层ChannelServiceImpl.java
package com.ysotek.wms.microservice.infrastructure.service.impl.tnb;
import com.ysotek.wms.microservice.core.model.PageModel;
import com.ysotek.wms.microservice.infrastructure.mapper.impl.IChannelListMapper;
import com.ysotek.wms.microservice.infrastructure.service.IChannelService;
import com.ysotek.wms.microservice.model.infrastructure.vo.IChannelListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Created by Cherry on 0012 12 十月.
*/
@Service("TnbChannelService")
public class ChannelServiceImpl implements IChannelService{
@Autowired
@Qualifier(value = "TnbChannelListMapper")
IChannelListMapper channelListMapper;
@Override
public PageModel queryChannels(Map map) {
List result=channelListMapper.getList(map);
Long total=channelListMapper.getCount(map);
return new PageModel(total,result);
}
@Override
public List queryChannelsList(Map map) {
return channelListMapper.getChannelsList(map);
}
@Override
public void createChannel() {
}
}
package com.ysotek.wms.microservice.infrastructure.service.impl.tnb;
import com.ysotek.wms.microservice.core.model.PageModel;
import com.ysotek.wms.microservice.infrastructure.mapper.impl.IChannelListMapper;
import com.ysotek.wms.microservice.infrastructure.service.IChannelService;
import com.ysotek.wms.microservice.model.infrastructure.vo.IChannelListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Created by Cherry on 0012 12 十月.
*/
@Service("TnbChannelService")
public class ChannelServiceImpl implements IChannelService{
@Autowired
@Qualifier(value = "TnbChannelListMapper")
IChannelListMapper channelListMapper;
@Override
public PageModel queryChannels(Map map) {
List result=channelListMapper.getList(map);
Long total=channelListMapper.getCount(map);
return new PageModel(total,result);
}
@Override
public List queryChannelsList(Map map) {
return channelListMapper.getChannelsList(map);
}
@Override
public void createChannel() {
}
}
package com.ysotek.wms.microservice.infrastructure.api;
import com.ysotek.wms.microservice.core.logging.LogSource;
import com.ysotek.wms.microservice.core.logging.WMSLogger;
import com.ysotek.wms.microservice.core.model.ApiReturnModel;
import com.ysotek.wms.microservice.core.model.PageModel;
import com.ysotek.wms.microservice.infrastructure.service.IChannelService;
import com.ysotek.wms.microservice.model.infrastructure.vo.IChannelListVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping( path = {"/api/tnb/infrastructure", "/api/dev/infrastructure","/api/demo/infrastructure"})
public class InfrastructureAPI {
@Autowired
@Qualifier(value = "TnbChannelService")
IChannelService channelService;
/**
*查询渠道商
*/
@RequestMapping(value = "/channel", method = {RequestMethod.GET})
@ResponseBody
public ApiReturnModel queryChannel(
@RequestParam(required = false) Integer from,
@RequestParam(required = false) Integer to,
@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer rows
){
WMSLogger.trace(LogSource.CHANNEL_QUERY,
String.format("渠道商查询开始"));
Map map = new HashMap();
if (rows == null){
rows = 20;
}
if (from == null){
if (page == null){
map.put("from",0);
}else{
from = (page - 1) * rows;
map.put("from",from);
}
}else{
map.put("from",from);
}
if (to == null){
map.put("to",rows);
}else{
map.put("to",to);
}
PageModel result = channelService.queryChannels(map);
WMSLogger.trace(LogSource.CHANNEL_QUERY, String.format("渠道商查询结束,结果条数 %s",result.getTotalNum()));
return new ApiReturnModel(200,result);
}
/**
* 根据id或name查询渠道商
* @param channelNameCn
* @return
*/
@RequestMapping(value = "/channels", method = {RequestMethod.GET})
@ResponseBody
public ApiReturnModel queryChannelDetailByName(@RequestParam(required = false) String channelId,
@RequestParam(required = false) String channelNameCn
){
WMSLogger.trace(LogSource.CHANNEL_QUERY,
String.format("单个渠道商查询开始,参数channelId:%s,channelNameCn:%s",channelId,channelNameCn));
Map map = new HashMap();
if (StringUtils.isNotBlank(channelId)){
map.put("channelId", channelId);
}
if (StringUtils.isNotBlank(channelNameCn)){
map.put("channelNameCn", "%"+channelNameCn+"%");
}
List channelListVOList=channelService.queryChannelsList(map);
if (channelListVOList == null){
return new ApiReturnModel(203,"订单不存在");
}
return new ApiReturnModel(200,channelListVOList);
}
@RequestMapping(method = {RequestMethod.POST})
@ResponseBody
public ApiReturnModel create(){
return null;
}
}