| @@ -34,11 +34,11 @@ public class WxMerchantController extends BaseController | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@ModelAttribute WxMerchant wxMerchant,String shopids, String userids) { | |||||
| public ResultData add(@RequestBody WxMerchant wxMerchant) { | |||||
| //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); | //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMerchant.setTenantId(getTenantId()); | wxMerchant.setTenantId(getTenantId()); | ||||
| wxMerchantService.saveOrUpdate(wxMerchant,shopids,userids); | |||||
| wxMerchantService.saveOrUpdate(wxMerchant); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -1,19 +1,17 @@ | |||||
| package com.simple.controller; | 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.github.pagehelper.PageInfo; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxMerchantShop; | import com.simple.domain.po.WxMerchantShop; | ||||
| import com.simple.domain.po.WxShop; | |||||
| import com.simple.service.WxMerchantShopService; | import com.simple.service.WxMerchantShopService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMerchantShop") | @RequestMapping("wxMerchantShop") | ||||
| @@ -35,6 +33,18 @@ public class WxMerchantShopController extends BaseController | |||||
| return new ResultData(page); | 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<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) { | public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) { | ||||
| @@ -37,8 +37,11 @@ public class WxMerchant implements Serializable { | |||||
| public void setIds(List<Long> ids) { | public void setIds(List<Long> ids) { | ||||
| this.ids = ids; | this.ids = ids; | ||||
| } | } | ||||
| @Transient | |||||
| private String userids; | |||||
| @Transient | |||||
| private String shopids; | |||||
| /*租户ID**/ | /*租户ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| @@ -152,6 +155,22 @@ public class WxMerchant implements Serializable { | |||||
| this.status = status; | 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 | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -39,6 +39,4 @@ public interface WxMerchantService { | |||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids); | |||||
| } | } | ||||
| @@ -1,8 +1,8 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxMerchantShop; | import com.simple.domain.po.WxMerchantShop; | ||||
| import com.simple.domain.po.WxShop; | |||||
| public interface WxMerchantShopService { | public interface WxMerchantShopService { | ||||
| @@ -37,12 +37,11 @@ public interface WxMerchantShopService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| PageInfo<WxShop> queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize); | |||||
| } | } | ||||
| @@ -37,9 +37,16 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | 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); | wxMerchantBUserMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| Date date = new Date(); | |||||
| record.setUpdateDate(date); | |||||
| wxMerchantBUserMapper.updateByPrimaryKeySelective(record); | wxMerchantBUserMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| } | } | ||||
| @@ -45,19 +45,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| return wxMerchantMapper.selectByPrimaryKey(id); | 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 | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| @@ -66,7 +53,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Transactional | @Transactional | ||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids) { | |||||
| public void saveOrUpdate(WxMerchant wxMerchant) { | |||||
| if (wxMerchant.getId() == null) { | if (wxMerchant.getId() == null) { | ||||
| @@ -79,7 +66,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantMapper.insertSelective(wxMerchant); | wxMerchantMapper.insertSelective(wxMerchant); | ||||
| //保存商户商铺的关联 | //保存商户商铺的关联 | ||||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||||
| List<Long> shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class); | |||||
| for(Long shopid:shopidlist){ | for(Long shopid:shopidlist){ | ||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | WxMerchantShop wxMerchantShop = new WxMerchantShop(); | ||||
| wxMerchantShop.setId(idWorker.nextId()); | wxMerchantShop.setId(idWorker.nextId()); | ||||
| @@ -101,7 +88,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| } | } | ||||
| //保存商户关联用户 | //保存商户关联用户 | ||||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||||
| List<Long> useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class); | |||||
| for(Long userid:useridlist){ | for(Long userid:useridlist){ | ||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | ||||
| wxMerchantBUser.setId(userid); | wxMerchantBUser.setId(userid); | ||||
| @@ -139,7 +126,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| //保存商户商铺的关联 | //保存商户商铺的关联 | ||||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||||
| List<Long> shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class); | |||||
| for(Long shopid:shopidlist){ | for(Long shopid:shopidlist){ | ||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | WxMerchantShop wxMerchantShop = new WxMerchantShop(); | ||||
| wxMerchantShop.setId(idWorker.nextId()); | wxMerchantShop.setId(idWorker.nextId()); | ||||
| @@ -162,7 +149,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| //保存商户关联用户 | //保存商户关联用户 | ||||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||||
| List<Long> useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class); | |||||
| for(Long userid:useridlist){ | for(Long userid:useridlist){ | ||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | ||||
| wxMerchantBUser.setId(userid); | wxMerchantBUser.setId(userid); | ||||
| @@ -1,14 +1,22 @@ | |||||
| package com.simple.service.impl; | 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.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.IdWorker; | |||||
| import com.simple.domain.po.WxMerchantShop; | import com.simple.domain.po.WxMerchantShop; | ||||
| import com.simple.domain.po.WxShop; | |||||
| import com.simple.mapper.WxMerchantShopMapper; | import com.simple.mapper.WxMerchantShopMapper; | ||||
| import com.simple.mapper.WxShopMapper; | |||||
| import com.simple.service.WxMerchantShopService; | import com.simple.service.WxMerchantShopService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | 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 | @Service | ||||
| public class WxMerchantShopServiceImpl implements WxMerchantShopService { | public class WxMerchantShopServiceImpl implements WxMerchantShopService { | ||||
| @@ -16,12 +24,33 @@ public class WxMerchantShopServiceImpl implements WxMerchantShopService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantShopMapper wxMerchantShopMapper; | WxMerchantShopMapper wxMerchantShopMapper; | ||||
| @Autowired | |||||
| WxShopMapper wxShopMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchantShop> listAsPage(WxMerchantShop record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchantShop> listAsPage(WxMerchantShop record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantShopMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantShopMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public PageInfo<WxShop> queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize) { | |||||
| List<WxShop> resultlist=new ArrayList<>(); | |||||
| List<WxMerchantShop> merchantShops = wxMerchantShopMapper.findList(record); | |||||
| for(WxMerchantShop merchantShop:merchantShops){ | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(merchantShop.getShopId()); | |||||
| List<WxShop> shopList = wxShopMapper.findList(wxShop); | |||||
| if(shopList.size()>0){ | |||||
| resultlist.add(shopList.get(0)); | |||||
| } | |||||
| } | |||||
| PageHelper.startPage(pageIndex, pageSize); | |||||
| PageInfo<WxShop> pageInfo = new PageInfo<>(resultlist); | |||||
| return pageInfo; | |||||
| } | |||||
| @Override | @Override | ||||
| public WxMerchantShop getById(Long id) { | public WxMerchantShop getById(Long id) { | ||||
| return wxMerchantShopMapper.selectByPrimaryKey(id); | return wxMerchantShopMapper.selectByPrimaryKey(id); | ||||