| @@ -33,7 +33,7 @@ public class WxBusinessController extends BaseController { | |||||
| @SystemControllerLog(description = "业态-全列表") | @SystemControllerLog(description = "业态-全列表") | ||||
| public ResultData listAll() { | public ResultData listAll() { | ||||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | ||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(); | |||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantId(),null); | |||||
| return new ResultData(busList); | return new ResultData(busList); | ||||
| } | } | ||||
| @@ -12,10 +12,7 @@ import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -29,22 +26,10 @@ public class WxBusinessController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxBusinessService wxBusinessService; | private WxBusinessService wxBusinessService; | ||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(WxBusiness wxBusiness, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | |||||
| final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("业态全列表接口") | @ApiOperation("业态全列表接口") | ||||
| @GetMapping("listAll") | @GetMapping("listAll") | ||||
| public ResultData listAll(@ModelAttribute WxBusiness wxBusiness) { | |||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(); | |||||
| public ResultData listAll(@RequestParam Integer filter) { | |||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantId(),filter); | |||||
| return new ResultData(busList); | return new ResultData(busList); | ||||
| } | } | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumBusinessFilter { | |||||
| // 1:商户 2:卡券 | |||||
| FILTER_BY_MERCHANT(1, "merchant"), | |||||
| FILTER_BY_COUPON(2, "coupon"), | |||||
| ; | |||||
| public static EnumBusinessFilter getEnum(Integer code) { | |||||
| for (EnumBusinessFilter value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumBusinessFilter(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -3,11 +3,13 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import io.lettuce.core.dynamic.annotation.Param; | |||||
| public interface WxBusinessMapper extends CommonMapper<WxBusiness, String> { | public interface WxBusinessMapper extends CommonMapper<WxBusiness, String> { | ||||
| List<WxBusiness> findList(WxBusiness wxBusiness); | List<WxBusiness> findList(WxBusiness wxBusiness); | ||||
| List<WxBusiness> findListAll(); | List<WxBusiness> findListAll(); | ||||
| List<WxBusiness> findListForMerchant(@Param("tenantId") String tenantId); | |||||
| List<WxBusiness> findListForCoupon(@Param("tenantId") String tenantId); | |||||
| } | } | ||||
| @@ -30,7 +30,7 @@ public interface WxBusinessService { | |||||
| * | * | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxBusiness> findListAll(); | |||||
| List<WxBusiness> findListAll(String tenantId, Integer filter); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -3,6 +3,8 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import com.iformall.enums.EnumBusiness; | |||||
| import com.iformall.enums.EnumBusinessFilter; | |||||
| import com.iformall.mapper.WxBusinessMapper; | import com.iformall.mapper.WxBusinessMapper; | ||||
| import com.iformall.service.WxBusinessService; | import com.iformall.service.WxBusinessService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -30,8 +32,15 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<WxBusiness> findListAll() { | |||||
| return wxBusinessMapper.findListAll(); | |||||
| public List<WxBusiness> findListAll(String tenantId, Integer filter) { | |||||
| if (filter == null) | |||||
| return wxBusinessMapper.findListAll(); | |||||
| else if (filter.equals(EnumBusinessFilter.FILTER_BY_COUPON.getCode())) | |||||
| return wxBusinessMapper.findListForCoupon(tenantId); | |||||
| else if (filter.equals(EnumBusinessFilter.FILTER_BY_MERCHANT.getCode())) | |||||
| return wxBusinessMapper.findListForMerchant(tenantId); | |||||
| else | |||||
| return wxBusinessMapper.findListAll(); | |||||
| } | } | ||||
| @@ -49,13 +49,38 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findListAll" parameterType="com.iformall.domain.po.WxBusiness" resultMap="BaseResultMap"> | |||||
| <select id="findListAll" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_business | select <include refid="allColumns" /> from wx_business | ||||
| order by create_date asc | order by create_date asc | ||||
| </select> | </select> | ||||
| <select id="findListForMerchant" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from wx_business b | |||||
| where | |||||
| (select count(*) from wx_merchant m | |||||
| where | |||||
| m.tenant_id = #{tenantId} | |||||
| and b.id = m.business_id | |||||
| and m.status = 0 | |||||
| and m.is_public = 1) > 0 | |||||
| order by create_date asc | |||||
| </select> | |||||
| <select id="findListForCoupon" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from wx_business b | |||||
| where | |||||
| (select count(*) from wx_coupon_channel cc | |||||
| where | |||||
| cc.tenant_id = #{tenantId} | |||||
| and b.id = cc.business | |||||
| and cc.status = 0 | |||||
| and cc.target_ad = 1) > 0 | |||||
| order by create_date asc | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -33,7 +33,7 @@ public class WxBusinessController extends BaseController { | |||||
| @SystemControllerLog(description = "业态-全列表") | @SystemControllerLog(description = "业态-全列表") | ||||
| public ResultData listAll() { | public ResultData listAll() { | ||||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | ||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(); | |||||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantId(),null); | |||||
| return new ResultData(busList); | return new ResultData(busList); | ||||
| } | } | ||||