diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java index 37034ab3e..00b496687 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java @@ -34,11 +34,11 @@ public class WxMerchantController extends BaseController @ApiOperation("新增接口") @PostMapping("add") - public ResultData add(@ModelAttribute WxMerchant wxMerchant,String shopids, String userids) { + public ResultData add(@RequestBody WxMerchant wxMerchant) { //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); wxMerchant.setTenantId(getTenantId()); - wxMerchantService.saveOrUpdate(wxMerchant,shopids,userids); + wxMerchantService.saveOrUpdate(wxMerchant); return new ResultData(); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java index f0c78f729..566c72eba 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java @@ -1,19 +1,17 @@ package com.simple.controller; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.*; - import com.github.pagehelper.PageInfo; import com.simple.common.Result; import com.simple.common.ResultData; - import com.simple.domain.po.WxMerchantShop; +import com.simple.domain.po.WxShop; import com.simple.service.WxMerchantShopService; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("wxMerchantShop") @@ -35,6 +33,18 @@ public class WxMerchantShopController extends BaseController return new ResultData(page); } + @ApiOperation("获取关联商铺信息") + @GetMapping("queryShopList") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop,Integer pageNum, Integer pageSize) { + if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); + final PageInfo page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增接口") @PostMapping("add") public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) { diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java b/mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java index 19f28ca54..e7fe5b37d 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java @@ -37,8 +37,11 @@ public class WxMerchant implements Serializable { public void setIds(List ids) { this.ids = ids; } - - + + @Transient + private String userids; + @Transient + private String shopids; /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") @@ -152,6 +155,22 @@ public class WxMerchant implements Serializable { this.status = status; } + public String getUserids() { + return userids; + } + + public void setUserids(String userids) { + this.userids = userids; + } + + public String getShopids() { + return shopids; + } + + public void setShopids(String shopids) { + this.shopids = shopids; + } + public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") diff --git a/mallinkService/src/main/java/com/simple/service/WxMerchantService.java b/mallinkService/src/main/java/com/simple/service/WxMerchantService.java index c5e2f6645..40f9af375 100644 --- a/mallinkService/src/main/java/com/simple/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/simple/service/WxMerchantService.java @@ -39,6 +39,4 @@ public interface WxMerchantService { void deleteById(Long id); - void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids); - } diff --git a/mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java b/mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java index 4184dd87a..7208a7646 100644 --- a/mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java +++ b/mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java @@ -1,8 +1,8 @@ package com.simple.service; -import java.util.*; import com.github.pagehelper.PageInfo; import com.simple.domain.po.WxMerchantShop; +import com.simple.domain.po.WxShop; public interface WxMerchantShopService { @@ -37,12 +37,11 @@ public interface WxMerchantShopService { * @param id */ void deleteById(Long id); - - - - - - + + + PageInfo queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize); + + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantBUserServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantBUserServiceImpl.java index f5279f232..845b38577 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantBUserServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantBUserServiceImpl.java @@ -37,9 +37,16 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + long id = idWorker.nextId(); + record.setId(id); + record.setBUserId(id); + Date date = new Date(); + record.setCreateDate(date); + record.setUpdateDate(date); wxMerchantBUserMapper.insertSelective(record); } else { + Date date = new Date(); + record.setUpdateDate(date); wxMerchantBUserMapper.updateByPrimaryKeySelective(record); } } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java index 3264ac35f..8c8cc6bc2 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java @@ -45,19 +45,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { return wxMerchantMapper.selectByPrimaryKey(id); } - @Override - public void saveOrUpdate(WxMerchant record) { - if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); - final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); - record.setCreateDate(new Date()); - - wxMerchantMapper.insertSelective(record); - } else { - wxMerchantMapper.updateByPrimaryKeySelective(record); - } - } @Override public void deleteById(Long id) { @@ -66,7 +53,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { @Transactional @Override - public void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids) { + public void saveOrUpdate(WxMerchant wxMerchant) { if (wxMerchant.getId() == null) { @@ -79,7 +66,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxMerchantMapper.insertSelective(wxMerchant); //保存商户商铺的关联 - List shopidlist = JSONArray.parseArray(shopids, Long.class); + List shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class); for(Long shopid:shopidlist){ WxMerchantShop wxMerchantShop = new WxMerchantShop(); wxMerchantShop.setId(idWorker.nextId()); @@ -101,7 +88,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { } //保存商户关联用户 - List useridlist = JSONArray.parseArray(userids, Long.class); + List useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class); for(Long userid:useridlist){ WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); wxMerchantBUser.setId(userid); @@ -139,7 +126,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { final IdWorker idWorker = IdWorker.get(); //保存商户商铺的关联 - List shopidlist = JSONArray.parseArray(shopids, Long.class); + List shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class); for(Long shopid:shopidlist){ WxMerchantShop wxMerchantShop = new WxMerchantShop(); wxMerchantShop.setId(idWorker.nextId()); @@ -162,7 +149,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { //保存商户关联用户 - List useridlist = JSONArray.parseArray(userids, Long.class); + List useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class); for(Long userid:useridlist){ WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); wxMerchantBUser.setId(userid); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java index 990924ebf..fdbf2cc5b 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java @@ -1,14 +1,22 @@ package com.simple.service.impl; -import java.util.*; +import com.github.pagehelper.ISelect; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.IdWorker; import com.simple.domain.po.WxMerchantShop; +import com.simple.domain.po.WxShop; import com.simple.mapper.WxMerchantShopMapper; +import com.simple.mapper.WxShopMapper; import com.simple.service.WxMerchantShopService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.simple.common.IdWorker; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Service public class WxMerchantShopServiceImpl implements WxMerchantShopService { @@ -16,12 +24,33 @@ public class WxMerchantShopServiceImpl implements WxMerchantShopService { @Autowired WxMerchantShopMapper wxMerchantShopMapper; + @Autowired + WxShopMapper wxShopMapper; + @Override public PageInfo listAsPage(WxMerchantShop record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantShopMapper.findList(record)); } + @Override + public PageInfo queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize) { + List resultlist=new ArrayList<>(); + + List merchantShops = wxMerchantShopMapper.findList(record); + for(WxMerchantShop merchantShop:merchantShops){ + WxShop wxShop = new WxShop(); + wxShop.setId(merchantShop.getShopId()); + List shopList = wxShopMapper.findList(wxShop); + if(shopList.size()>0){ + resultlist.add(shopList.get(0)); + } + } + PageHelper.startPage(pageIndex, pageSize); + PageInfo pageInfo = new PageInfo<>(resultlist); + return pageInfo; + } + @Override public WxMerchantShop getById(Long id) { return wxMerchantShopMapper.selectByPrimaryKey(id);