parent
fc3c6e5125
commit
7d49ac94c3
@ -0,0 +1,196 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighMerchant; |
||||
import com.hai.entity.HighMerchantStore; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighMerchantService; |
||||
import com.hai.service.HighMerchantStoreService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: |
||||
* @Date: 2021/3/9 20:58 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/highMerchantStore") |
||||
@Api(value = "商户门店接口") |
||||
public class HighMerchantStoreController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighMerchantStoreService highMerchantStoreService; |
||||
|
||||
@Resource |
||||
private HighMerchantService highMerchantService; |
||||
|
||||
@RequestMapping(value="/editHighMerchantStore",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑商户门店") |
||||
public ResponseData editMerchantStore(@RequestBody HighMerchantStore highMerchantStore, HttpServletRequest request) { |
||||
try { |
||||
//发布人员
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (highMerchantStore.getMerchantId() == null |
||||
|| StringUtils.isNotBlank(highMerchantStore.getStoreKey()) |
||||
|| StringUtils.isNotBlank(highMerchantStore.getStoreName()) |
||||
|| StringUtils.isNotBlank(highMerchantStore.getTelephone()) |
||||
|| StringUtils.isNotBlank(highMerchantStore.getAddress()) |
||||
) { |
||||
log.error("HighMerchantStoreController -> editMerchantStore() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 商户
|
||||
HighMerchant merchant = highMerchantService.getMerchantById(highMerchantStore.getMerchantId()); |
||||
if (merchant != null) { |
||||
log.error("HighMerchantStoreController -> editMerchantStore() error!","未找到商户"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
||||
} |
||||
if (highMerchantStore.getId() != null) { |
||||
highMerchantStore.setUpdateTime(new Date()); |
||||
} else { |
||||
highMerchantStore.setCreateTime(new Date()); |
||||
highMerchantStore.setUpdateTime(new Date()); |
||||
} |
||||
|
||||
highMerchantStore.setCompanyId(merchant.getCompanyId()); |
||||
highMerchantStore.setStatus(1); // 状态:0:删除,1:正常
|
||||
highMerchantStore.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
highMerchantStore.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
highMerchantStoreService.editMerchantStore(highMerchantStore); |
||||
|
||||
return ResponseMsgUtil.success(highMerchantStore); |
||||
} catch (Exception e) { |
||||
log.error("HighMerchantStoreController -> editMerchantStore() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/deleteMerchantStore",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除商户门店") |
||||
public ResponseData deleteMerchantStore(@RequestParam(name = "id", required = true) Long id) { |
||||
try { |
||||
// 商户门店
|
||||
HighMerchantStore merchantStore = highMerchantStoreService.getMerchantStoreById(id); |
||||
if(merchantStore == null) { |
||||
log.error("HighMerchantStoreController -> deleteMerchantStore() error!","未找到商户门店"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_STORE_NOF_FOUND, ""); |
||||
} |
||||
merchantStore.setStatus(0); |
||||
merchantStore.setUpdateTime(new Date()); |
||||
highMerchantStoreService.editMerchantStore(merchantStore); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighMerchantStoreController -> deleteMerchantStore() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getMerchantStoreById",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询商户门店") |
||||
public ResponseData getMerchantStoreById(@RequestParam(name = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(highMerchantStoreService.getMerchantStoreById(id)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighMerchantStoreController -> getMerchantStoreById() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getStoreListByCompany",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据公司 查询商户门店列表") |
||||
public ResponseData getStoreListByCompany(@RequestParam(name = "merchantId", required = false) Long merchantId, |
||||
@RequestParam(name = "telephone", required = false) String telephone, |
||||
@RequestParam(name = "storeName", required = false) String storeName, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (userInfoModel.getBsCompany() == null) { |
||||
log.error("HighMerchantStoreController -> getStoreListByCompany() error!","权限不足"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||
} |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("companyId", userInfoModel.getBsCompany().getId()); |
||||
map.put("merchantId", merchantId); |
||||
map.put("telephone", telephone); |
||||
map.put("storeName", storeName); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highMerchantStoreService.getMerchantStoreList(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighMerchantStoreController -> getStoreListByCompany() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getStoreListByMerchant",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据商户 查询门店列表") |
||||
public ResponseData getStoreListByMerchant(@RequestParam(name = "telephone", required = false) String telephone, |
||||
@RequestParam(name = "storeName", required = false) String storeName, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (userInfoModel.getMerchant() == null) { |
||||
log.error("HighMerchantStoreController -> getStoreListByMerchant() error!","权限不足"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||
} |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("merchantId", userInfoModel.getMerchant().getId()); |
||||
map.put("telephone", telephone); |
||||
map.put("storeName", storeName); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highMerchantStoreService.getMerchantStoreList(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighMerchantStoreController -> getStoreListByMerchant() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,36 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighMerchantStore; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 门店服务 |
||||
* @Date 2021/3/9 20:15 |
||||
**/ |
||||
public interface HighMerchantStoreService { |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 编辑门店 |
||||
* @Date 2021/3/9 20:26 |
||||
**/ |
||||
void editMerchantStore(HighMerchantStore highMerchantStore); |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 根据id查询 |
||||
* @Date 2021/3/9 20:26 |
||||
**/ |
||||
HighMerchantStore getMerchantStoreById(Long id); |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 查询门店列表 |
||||
* @Date 2021/3/9 20:26 |
||||
**/ |
||||
List<HighMerchantStore> getMerchantStoreList(Map<String, Object> map); |
||||
|
||||
} |
@ -1,4 +0,0 @@ |
||||
package com.hai.service; |
||||
|
||||
public interface HighStoreService { |
||||
} |
@ -0,0 +1,64 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
|
||||
import com.hai.dao.HighMerchantStoreMapper; |
||||
import com.hai.entity.HighMerchantStore; |
||||
import com.hai.entity.HighMerchantStoreExample; |
||||
import com.hai.service.HighMerchantStoreService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("highMerchantStoreService") |
||||
public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { |
||||
|
||||
@Resource |
||||
private HighMerchantStoreMapper highMerchantStoreMapper; |
||||
|
||||
@Override |
||||
public void editMerchantStore(HighMerchantStore highMerchantStore) { |
||||
if (highMerchantStore.getId() != null) { |
||||
highMerchantStoreMapper.updateByPrimaryKey(highMerchantStore); |
||||
} else { |
||||
highMerchantStoreMapper.insert(highMerchantStore); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HighMerchantStore getMerchantStoreById(Long id) { |
||||
return highMerchantStoreMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighMerchantStore> getMerchantStoreList(Map<String, Object> map) { |
||||
HighMerchantStoreExample example = new HighMerchantStoreExample(); |
||||
HighMerchantStoreExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getLong(map, "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(map, "merchantId") != null) { |
||||
criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(map, "storeKey"))) { |
||||
criteria.andStoreKeyEqualTo(MapUtils.getString(map, "storeKey")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(map, "storeName"))) { |
||||
criteria.andStoreNameLike("%" + MapUtils.getString(map, "storeName") + "%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(map, "telephone"))) { |
||||
criteria.andTelephoneEqualTo("%" + MapUtils.getString(map, "telephone") + "%"); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return highMerchantStoreMapper.selectByExample(example); |
||||
} |
||||
} |
@ -1,5 +0,0 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
|
||||
public class HighStoreServiceImpl { |
||||
} |
Loading…
Reference in new issue