|
@@ -1,16 +1,24 @@
|
|
package com.qs.mp.web.controller.api.channel;
|
|
package com.qs.mp.web.controller.api.channel;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
|
+import com.qs.mp.channel.domain.ChannelAddr;
|
|
|
|
+import com.qs.mp.channel.domain.param.ChannelParam;
|
|
import com.qs.mp.channel.domain.vo.ChannelVO;
|
|
import com.qs.mp.channel.domain.vo.ChannelVO;
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
|
|
+import com.qs.mp.utils.SecurityUtils;
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import ma.glasnost.orika.MapperFacade;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -18,6 +26,7 @@ import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -34,50 +43,88 @@ import org.springframework.web.bind.annotation.RestController;
|
|
@Component
|
|
@Component
|
|
public class ChannelController extends BaseApiController {
|
|
public class ChannelController extends BaseApiController {
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IChannelService channelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IChannelService channelService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private BizIdGenerator bizIdGenerator;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MapperFacade mapperFacade;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 子渠道列表查询
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("subchannel/list")
|
|
|
|
+ public TableDataInfo list(@RequestBody Channel channel) {
|
|
|
|
+ startPage();
|
|
|
|
+ List<Channel> list = channelService.list(new LambdaQueryWrapper<Channel>());
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取我的下级渠道详情信息
|
|
|
|
+ *
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "subchannel/detail")
|
|
|
|
+ public AjaxResult getInfo(@RequestBody Channel channel) {
|
|
|
|
+ if (null == channel || null == channel.getChannelId()) {
|
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long channelId = channel.getChannelId();
|
|
|
|
+ ChannelVO channelVO = new ChannelVO();
|
|
|
|
+ Channel queryChannel = channelService.getById(channelId);
|
|
|
|
+ BeanUtils.copyProperties(queryChannel, channelVO);
|
|
|
|
+ return AjaxResult.success(channelVO);
|
|
|
|
+ }
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private BizIdGenerator bizIdGenerator;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 增子渠道信息
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = "新增子渠道信息", notes = "渠道端新增子渠道")
|
|
|
|
+ @PostMapping("subchannel/create")
|
|
|
|
+ public AjaxResult addChannel(@Validated @RequestBody ChannelParam channelParam) {
|
|
|
|
+ if (channelParam.getChannelId() != null && channelParam.getChannelId() != 0) {
|
|
|
|
+ return AjaxResult.error("该渠道已存在");
|
|
|
|
+ }
|
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
|
|
|
- /**
|
|
|
|
- * 子渠道列表查询
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @PostMapping("subchannel/list")
|
|
|
|
- public TableDataInfo list(@RequestBody Channel channel) {
|
|
|
|
|
|
+ Channel channel = mapperFacade.map(channelParam, Channel.class);
|
|
|
|
+ channel.setParentId(channelId);
|
|
|
|
+ try {
|
|
|
|
+ channelService.saveChannel(channel);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return AjaxResult.error("新增子渠道信息'" + channel.getName() + "'失败");
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("新增子渠道信息'" + channel.getName() + "'成功");
|
|
|
|
+ }
|
|
|
|
|
|
- startPage();
|
|
|
|
- List<Channel> list = channelService.list(new LambdaQueryWrapper<Channel>());
|
|
|
|
- return getDataTable(list);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取我的下级渠道详情信息
|
|
|
|
- *
|
|
|
|
- * @param
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @PostMapping(value = "subchannel/detail")
|
|
|
|
- public AjaxResult getInfo(@RequestBody Channel channel) {
|
|
|
|
- if (null == channel || null == channel.getChannelId()) {
|
|
|
|
- return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
|
- }
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 编辑子渠道信息
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = "编辑子渠道信息", notes = "渠道端编辑子渠道")
|
|
|
|
+ @PostMapping("subchannel/update")
|
|
|
|
+ public AjaxResult editChannel(@Validated @RequestBody ChannelParam channelParam) {
|
|
|
|
|
|
- Long channelId = channel.getChannelId();
|
|
|
|
- ChannelVO channelVO = new ChannelVO();
|
|
|
|
-// try {
|
|
|
|
-// Customer queryCustomer = customerService.getById(custId);
|
|
|
|
-// BeanUtils.copyProperties(queryCustomer, queryCustomerVO);
|
|
|
|
-// int totalShopCnt = shopService.count(new QueryWrapper<Shop>().lambda()
|
|
|
|
-// .eq(Shop::getCustId, hostHolder.getUser().getCustId()).in(Shop::getShopType, ShopTypeEnum.getShopTypes()));
|
|
|
|
-// queryCustomerVO.setShopNum(totalShopCnt);
|
|
|
|
-// } catch (DataOperationException e) {
|
|
|
|
-// return AjaxResult.error(e.getCode(), e.getMessage(), null);
|
|
|
|
-// }
|
|
|
|
- return AjaxResult.success(channelVO);
|
|
|
|
- }
|
|
|
|
|
|
+ if (null == channelParam || null == channelParam.getChannelId()) {
|
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
|
+ }
|
|
|
|
+ Channel channel = mapperFacade.map(channelParam, Channel.class);
|
|
|
|
+ try {
|
|
|
|
+ channelService.updateChannel(channel);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return AjaxResult.error("编辑子渠道信息'" + channel.getName() + "'失败");
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("编辑子渠道信息'" + channel.getName() + "'成功");
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|