Commit 617718e5 by zzrdark

1.渠道号模块完成

parent eb4daa0e
package com.mx.cneeds.server.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
......@@ -13,6 +14,7 @@ import java.util.Date;
* @Description TODO
**/
@Data
@TableName("device_channel")
public class DeviceChannelEntity implements Serializable {
/**
......
package com.mx.cneeds.server.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
......@@ -12,6 +13,7 @@ import java.io.Serializable;
* @Description TODO
**/
@Data
@TableName("device_info_channel")
public class DeviceInfoChannelEntity implements Serializable {
@TableId
......
<?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="com.mx.cneeds.server.dao.DeviceChannelDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.mx.cneeds.server.entity.DeviceChannelEntity" id="deviceChannelMap">
<result property="channelId" column="channel_id"/>
<result property="channelNum" column="channel_num"/>
<result property="brand" column="brand"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
<?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="com.mx.cneeds.server.dao.DeviceInfoChannelDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.mx.cneeds.server.entity.DeviceInfoChannelEntity" id="deviceInfoChannelMap">
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="channelId" column="channel_id"/>
</resultMap>
</mapper>
\ No newline at end of file
package com.mx.cneeds.common.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName DeviceChannelEntity
* @Author zzrdark
* @Date 2020-05-09 15:28
* @Description TODO
**/
@Data
public class ChannelVo implements Serializable {
/**
* 渠道号Id
*/
private Long channelId;
/**
* 渠道号
*/
private String channelNum;
/**
* 品牌
*/
private String brand;
}
package com.mx.cneeds.server.datashow.client;
import com.mx.cneeds.common.dto.DeviceInfoDto;
import com.mx.cneeds.common.dto.DevicesDto;
import com.mx.cneeds.common.dto.PageDto;
import com.mx.cneeds.common.dto.SeriesDto;
import com.mx.cneeds.common.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -67,4 +64,27 @@ public interface DeviceClient {
@PostMapping("/device/info/delete")
void deleteDevice(@RequestBody List<Long> ids);
@PostMapping("/device/devicechannel/list")
PageDto deviceChannelList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField,
@RequestParam("order") String order);
/**
* 增加一个渠道号
* @param dto
*/
@PostMapping("/device/devicechannel/save")
void addDeviceChannel(@RequestBody DeviceChannelDto dto);
@PostMapping("/device/devicechannel/queryDeviceChannel")
DeviceChannelDto queryDeviceChannel(@RequestBody String channelNum);
@PostMapping("/device/devicechannel/update")
void updateDeviceChannel(@RequestBody DeviceChannelDto dto);
@PostMapping("/device/devicechannel/delete")
void deleteDeviceChannels(@RequestBody List<Long> ids);
}
......@@ -4,6 +4,7 @@ import com.mx.cneeds.common.constant.ResultCode;
import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.ChannelVo;
import com.mx.cneeds.common.vo.DeviceChannelVo;
import com.mx.cneeds.common.vo.DevicesVo;
import com.mx.cneeds.common.vo.SeriesVo;
......@@ -209,4 +210,67 @@ public class DeviceController {
}
@PostMapping("/deviceChannel/list")
public R deivceChannelList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String sort){
String orderField = null;
String order = null;
if (page==null || page==0){
page = new Integer(1);
}
if (pageSize==null || pageSize==0){
pageSize = new Integer(10);
}
if (StringUtils.isNotEmpty(sort) && StringUtils.isNotBlank(sort.trim())){
if (sort.contains("+")){
order = new String("asc");
}
if (sort.contains("-")){
order = new String("desc");
}
orderField = sort.substring(1);
orderField = RequestParamterConverter.toLine(orderField);
}
PageDto pageDto = deviceClient.deviceChannelList(page,pageSize,orderField,order);
return new R().put("data",pageDto);
}
@PostMapping("/deviceChannel/add")
public R addDeviceChannel(ChannelVo vo){
DeviceChannelDto dto = deviceClient.queryDeviceChannel(vo.getChannelNum());
if (dto != null){
return R.error(ResultCode.DATA_REPEATITION,"渠道号重复");
}
DeviceChannelDto deviceChannelDto = new DeviceChannelDto();
BeanUtils.copyProperties(vo,deviceChannelDto);
deviceClient.addDeviceChannel(deviceChannelDto);
return R.ok();
}
@PostMapping("/deviceChannel/edit")
public R editSeries(ChannelVo vo){
DeviceChannelDto deviceChannelDto = new DeviceChannelDto();
BeanUtils.copyProperties(vo,deviceChannelDto);
deviceClient.updateDeviceChannel(deviceChannelDto);
return R.ok();
}
@PostMapping("/deviceChannel/delete")
public R deleteDeviceChannel(@RequestParam(value = "ids",required = false) List<Long> ids){
deviceClient.deleteDeviceChannels(ids);
return R.ok();
}
}
spring:
profiles:
active: prod
active: dev
application:
name: cneeds-server-datashow
server:
......
......@@ -20,5 +20,7 @@ public interface DeviceChannelService extends IService<DeviceChannelEntity> {
PageUtils queryPage(Map<String, Object> params);
DeviceChannelEntity queryDeviceChannel(String channelNum);
}
......@@ -26,4 +26,11 @@ public class DeviceChannelServiceImpl extends ServiceImpl<DeviceChannelDao, Devi
return new PageUtils(page);
}
@Override
public DeviceChannelEntity queryDeviceChannel(String channelNum){
DeviceChannelEntity channelEntity = getOne(new QueryWrapper<DeviceChannelEntity>().eq("channel_num", channelNum));
return channelEntity;
}
}
......@@ -17,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName DeviceChannelController
......@@ -30,7 +27,7 @@ import java.util.Map;
**/
@RestController
@RequestMapping("/devicechannel")
@RequestMapping("device/devicechannel")
public class DeviceChannelController {
@Autowired
......@@ -46,11 +43,11 @@ public class DeviceChannelController {
@RequestMapping("/list")
public PageUtils list(@RequestParam Map<String, Object> params){
PageUtils page = deviceChannelService.queryPage(params);
List<SeriesDto> list = new ArrayList<SeriesDto>();
List<DeviceChannelDto> list = new ArrayList<DeviceChannelDto>();
for (Object entity : page.getList()){
SeriesDto dto = new SeriesDto();
ProductSeriesEntity seriesEntity = (ProductSeriesEntity) entity;
BeanUtils.copyProperties(seriesEntity,dto);
DeviceChannelDto dto = new DeviceChannelDto();
DeviceChannelEntity deviceChannelEntity = (DeviceChannelEntity) entity;
BeanUtils.copyProperties(deviceChannelEntity,dto);
list.add(dto);
}
return page;
......@@ -65,6 +62,8 @@ public class DeviceChannelController {
DeviceChannelEntity deviceChannelEntity = new DeviceChannelEntity();
BeanUtils.copyProperties(deviceChannelDto,deviceChannelEntity);
deviceChannelEntity.setUpdateTime(new Date());
deviceChannelService.save(deviceChannelEntity);
return R.ok();
......@@ -78,6 +77,8 @@ public class DeviceChannelController {
ValidatorUtils.validateEntity(deviceChannelDto);
DeviceChannelEntity deviceChannelEntity = new DeviceChannelEntity();
BeanUtils.copyProperties(deviceChannelDto,deviceChannelEntity);
deviceChannelEntity.setUpdateTime(new Date());
deviceChannelService.updateById(deviceChannelEntity);
return R.ok();
......@@ -92,4 +93,17 @@ public class DeviceChannelController {
return R.ok();
}
@RequestMapping("/queryDeviceChannel")
public DeviceChannelDto queryDeviceChannel(String channelNum){
DeviceChannelEntity deviceChannelEntity = deviceChannelService.queryDeviceChannel(channelNum);
DeviceChannelDto dto = new DeviceChannelDto();
if (deviceChannelEntity == null) {
return null;
}
BeanUtils.copyProperties(deviceChannelEntity,dto);
return dto;
}
}
spring:
profiles:
active: prod
active: dev
application:
name: cneeds-server-device
......
spring:
profiles:
active: prod
active: dev
application:
name: cneeds-server-logupload
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment