parent
bc96ce8b4a
commit
e492ea590d
@ -0,0 +1,132 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
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.AESEncodeUtil; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.MD5Util; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.MenuTreeModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighMerchantService; |
||||
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 javax.servlet.http.HttpServletResponse; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: |
||||
* @Date: 2021/3/8 21:55 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/highMerchant") |
||||
@Api(value = "商户接口") |
||||
public class HighMerchantController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighMerchantController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighMerchantService highMerchantService; |
||||
|
||||
@RequestMapping(value="/editMerchant",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑商户") |
||||
public ResponseData editMerchant(@RequestBody HighMerchant highMerchant, HttpServletRequest request) { |
||||
try { |
||||
//发布人员
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (highMerchant.getCompanyId() == null |
||||
|| StringUtils.isBlank(highMerchant.getMerchantKey()) |
||||
|| StringUtils.isBlank(highMerchant.getMerchantName()) |
||||
|| StringUtils.isBlank(highMerchant.getTelephone()) |
||||
|| StringUtils.isBlank(highMerchant.getAddress()) |
||||
) { |
||||
log.error("HighMerchantController -> editMerchant() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
if (highMerchant.getId() != null) { |
||||
if (highMerchantService.getMerchantById(highMerchant.getId()) == null) { |
||||
log.error("HighMerchantController -> editMerchant() error!","未找到商户"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
||||
} |
||||
highMerchant.setUpdateTime(new Date()); |
||||
|
||||
} else { |
||||
highMerchant.setCreateTime(new Date()); |
||||
highMerchant.setUpdateTime(new Date()); |
||||
} |
||||
highMerchant.setStatus(1); // 状态:0:不可用,1:可用
|
||||
highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
highMerchantService.editMerchant(highMerchant); |
||||
|
||||
return ResponseMsgUtil.success(highMerchant); |
||||
} catch (Exception e) { |
||||
log.error("HighMerchantController -> editMerchant() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getMerchantById",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询商户") |
||||
public ResponseData getMerchantById(@RequestParam(name = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(highMerchantService.getMerchantById(id)); |
||||
} catch (Exception e) { |
||||
log.error("HighMerchantController -> getMerchantById() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getMerchantList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询商户列表") |
||||
public ResponseData getMerchantList(@RequestParam(name = "companyId", required = true) Long companyId, |
||||
@RequestParam(name = "merchantKey", required = true) String merchantKey, |
||||
@RequestParam(name = "merchantName", required = true) String merchantName, |
||||
@RequestParam(name = "telephone", required = true) String telephone, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("companyId", companyId); |
||||
map.put("merchantKey", merchantKey); |
||||
map.put("merchantName", merchantName); |
||||
map.put("telephone", telephone); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highMerchantService.getMerchantList(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighMerchantController -> getMerchantList() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -1,7 +0,0 @@ |
||||
package com.hai.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface HighMemberPayPasswordMapperExt { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hai.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface HighUserPayPasswordMapperExt { |
||||
} |
@ -0,0 +1,32 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighMerchant; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 商户业务 |
||||
*/ |
||||
public interface HighMerchantService { |
||||
|
||||
/** |
||||
* 编辑 |
||||
*/ |
||||
void editMerchant(HighMerchant highMerchant); |
||||
|
||||
/** |
||||
* 根据id查询 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
HighMerchant getMerchantById(Long id); |
||||
|
||||
/** |
||||
* 查询列表 |
||||
* @param map |
||||
* @return |
||||
*/ |
||||
List<HighMerchant> getMerchantList(Map<String,Object> map); |
||||
|
||||
} |
@ -0,0 +1,4 @@ |
||||
package com.hai.service; |
||||
|
||||
public interface HighStoreService { |
||||
} |
@ -0,0 +1,59 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighMerchantMapper; |
||||
import com.hai.entity.HighMerchant; |
||||
import com.hai.entity.HighMerchantExample; |
||||
import com.hai.service.HighMerchantService; |
||||
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("highMerchantService") |
||||
public class HighMerchantServiceImpl implements HighMerchantService { |
||||
|
||||
@Resource |
||||
private HighMerchantMapper highMerchantMapper; |
||||
|
||||
@Override |
||||
public void editMerchant(HighMerchant highMerchant) { |
||||
if (highMerchant.getId() == null) { |
||||
highMerchantMapper.insert(highMerchant); |
||||
} else { |
||||
highMerchantMapper.updateByPrimaryKey(highMerchant); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HighMerchant getMerchantById(Long id) { |
||||
return highMerchantMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighMerchant> getMerchantList(Map<String, Object> map) { |
||||
HighMerchantExample example = new HighMerchantExample(); |
||||
HighMerchantExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (map.get("companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLongValue(map, "companyId")); |
||||
} |
||||
|
||||
if (map.get("merchantKey") != null) { |
||||
criteria.andMerchantKeyEqualTo(MapUtils.getString(map, "merchantKey")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(map, "merchantName"))) { |
||||
criteria.andMerchantNameLike("%" + MapUtils.getString(map, "merchantName") + "%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(map, "telephone"))) { |
||||
criteria.andTelephoneEqualTo(MapUtils.getString(map, "telephone")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return highMerchantMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
|
||||
public class HighStoreServiceImpl { |
||||
} |
Loading…
Reference in new issue