'完成商户接口'

dev-discount
199901012 4 years ago
parent bc96ce8b4a
commit e492ea590d
  1. 132
      hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java
  2. 3
      hai-service/src/main/java/com/hai/common/exception/ErrorCode.java
  3. 33
      hai-service/src/main/java/com/hai/common/security/UserCenter.java
  4. 7
      hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapperExt.java
  5. 48
      hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapper.java
  6. 7
      hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapperExt.java
  7. 42
      hai-service/src/main/java/com/hai/dao/HighUserPayPasswordSqlProvider.java
  8. 6
      hai-service/src/main/java/com/hai/entity/HighUserPayPassword.java
  9. 4
      hai-service/src/main/java/com/hai/entity/HighUserPayPasswordExample.java
  10. 32
      hai-service/src/main/java/com/hai/service/HighMerchantService.java
  11. 4
      hai-service/src/main/java/com/hai/service/HighStoreService.java
  12. 59
      hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java
  13. 5
      hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java

@ -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);
}
}
}

@ -74,6 +74,7 @@ public enum ErrorCode {
PASSWORD_ERROR("2102","密码错误"),
SMS_CODE_ERROR("2103","验证码错误"),
ID_CARD_NUM_IS_ERROR("2104","身份证号码错误"),
MERCHANT_NOF_FOUND("2105","未找到商户"),
STATUS_ERROR("3000","状态错误"),
ADD_DATA_ERROR("3001","增加数据失败"),
@ -81,7 +82,7 @@ public enum ErrorCode {
DELETE_DATA_ERROR("3003","删除数据失败"),
MSG_EVENT_NULL("2999","消息类型为空"),
USE_VISIT_ILLEGAL("4001","请登录"),
USE_VISIT_ILLEGAL("4001","用户身份错误"),
RC_VISIT_ERROR("2998",""),
UNKNOW_ERROR("999999","未知异常"),
EXCEL_ERROR("80000","Excel处理异常"),

@ -1,6 +1,9 @@
package com.hai.common.security;
import com.fasterxml.jackson.core.JsonParseException;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -94,27 +97,19 @@ public class UserCenter {
}
}
public static SessionObject getSessionObject(HttpServletRequest request) throws Exception{
public static SessionObject getSessionObject(HttpServletRequest request) throws Exception {
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token)){
if (StringUtils.isBlank(token)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USE_VISIT_ILLEGAL, "");
}
if (LoginCache.getData(token) != null) {
return LoginCache.getData(token);
//通过token方式登录
/*String value = AESEncodeUtil.aesDecrypt(token);
if(!StringUtils.isEmpty(value)){
return LoginCache.getData(token);
}*/
}else{
String jo = read(request);
if(StringUtils.isNotBlank(jo)){
try {
return LoginCache.getData(jo);
} catch (Exception e) {
log.error("get SessionObject from usercenter failed");
return null;
}
}
}
return null;
}
if (read(request) != null) {
return LoginCache.getData(token);
}
return LoginCache.getData(token);
}
/**
* @param request

@ -1,7 +0,0 @@
package com.hai.dao;
/**
* mapper扩展类
*/
public interface HighMemberPayPasswordMapperExt {
}

@ -1,7 +1,7 @@
package com.hai.dao;
import com.hai.entity.HighMemberPayPassword;
import com.hai.entity.HighMemberPayPasswordExample;
import com.hai.entity.HighUserPayPassword;
import com.hai.entity.HighUserPayPasswordExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
@ -25,21 +25,21 @@ import org.springframework.stereotype.Repository;
*
**/
@Repository
public interface HighMemberPayPasswordMapper extends HighMemberPayPasswordMapperExt {
@SelectProvider(type=HighMemberPayPasswordSqlProvider.class, method="countByExample")
long countByExample(HighMemberPayPasswordExample example);
public interface HighUserPayPasswordMapper extends HighUserPayPasswordMapperExt {
@SelectProvider(type=HighUserPayPasswordSqlProvider.class, method="countByExample")
long countByExample(HighUserPayPasswordExample example);
@DeleteProvider(type=HighMemberPayPasswordSqlProvider.class, method="deleteByExample")
int deleteByExample(HighMemberPayPasswordExample example);
@DeleteProvider(type=HighUserPayPasswordSqlProvider.class, method="deleteByExample")
int deleteByExample(HighUserPayPasswordExample example);
@Delete({
"delete from high_member_pay_password",
"delete from high_user_pay_password",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_member_pay_password (user_id, user_phone, ",
"insert into high_user_pay_password (user_id, user_phone, ",
"`password`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
@ -49,13 +49,13 @@ public interface HighMemberPayPasswordMapper extends HighMemberPayPasswordMapper
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighMemberPayPassword record);
int insert(HighUserPayPassword record);
@InsertProvider(type=HighMemberPayPasswordSqlProvider.class, method="insertSelective")
@InsertProvider(type=HighUserPayPasswordSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(HighMemberPayPassword record);
int insertSelective(HighUserPayPassword record);
@SelectProvider(type=HighMemberPayPasswordSqlProvider.class, method="selectByExample")
@SelectProvider(type=HighUserPayPasswordSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@ -67,13 +67,13 @@ public interface HighMemberPayPasswordMapper extends HighMemberPayPasswordMapper
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<HighMemberPayPassword> selectByExample(HighMemberPayPasswordExample example);
List<HighUserPayPassword> selectByExample(HighUserPayPasswordExample example);
@Select({
"select",
"id, user_id, user_phone, `password`, create_time, update_time, ext_1, ext_2, ",
"ext_3",
"from high_member_pay_password",
"from high_user_pay_password",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@ -87,19 +87,19 @@ public interface HighMemberPayPasswordMapper extends HighMemberPayPasswordMapper
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
HighMemberPayPassword selectByPrimaryKey(Long id);
HighUserPayPassword selectByPrimaryKey(Long id);
@UpdateProvider(type=HighMemberPayPasswordSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") HighMemberPayPassword record, @Param("example") HighMemberPayPasswordExample example);
@UpdateProvider(type=HighUserPayPasswordSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") HighUserPayPassword record, @Param("example") HighUserPayPasswordExample example);
@UpdateProvider(type=HighMemberPayPasswordSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") HighMemberPayPassword record, @Param("example") HighMemberPayPasswordExample example);
@UpdateProvider(type=HighUserPayPasswordSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") HighUserPayPassword record, @Param("example") HighUserPayPasswordExample example);
@UpdateProvider(type=HighMemberPayPasswordSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(HighMemberPayPassword record);
@UpdateProvider(type=HighUserPayPasswordSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(HighUserPayPassword record);
@Update({
"update high_member_pay_password",
"update high_user_pay_password",
"set user_id = #{userId,jdbcType=BIGINT},",
"user_phone = #{userPhone,jdbcType=BIGINT},",
"`password` = #{password,jdbcType=VARCHAR},",
@ -110,5 +110,5 @@ public interface HighMemberPayPasswordMapper extends HighMemberPayPasswordMapper
"ext_3 = #{ext3,jdbcType=VARCHAR}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(HighMemberPayPassword record);
int updateByPrimaryKey(HighUserPayPassword record);
}

@ -0,0 +1,7 @@
package com.hai.dao;
/**
* mapper扩展类
*/
public interface HighUserPayPasswordMapperExt {
}

@ -1,32 +1,32 @@
package com.hai.dao;
import com.hai.entity.HighMemberPayPassword;
import com.hai.entity.HighMemberPayPasswordExample.Criteria;
import com.hai.entity.HighMemberPayPasswordExample.Criterion;
import com.hai.entity.HighMemberPayPasswordExample;
import com.hai.entity.HighUserPayPassword;
import com.hai.entity.HighUserPayPasswordExample.Criteria;
import com.hai.entity.HighUserPayPasswordExample.Criterion;
import com.hai.entity.HighUserPayPasswordExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class HighMemberPayPasswordSqlProvider {
public class HighUserPayPasswordSqlProvider {
public String countByExample(HighMemberPayPasswordExample example) {
public String countByExample(HighUserPayPasswordExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("high_member_pay_password");
sql.SELECT("count(*)").FROM("high_user_pay_password");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(HighMemberPayPasswordExample example) {
public String deleteByExample(HighUserPayPasswordExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("high_member_pay_password");
sql.DELETE_FROM("high_user_pay_password");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(HighMemberPayPassword record) {
public String insertSelective(HighUserPayPassword record) {
SQL sql = new SQL();
sql.INSERT_INTO("high_member_pay_password");
sql.INSERT_INTO("high_user_pay_password");
if (record.getUserId() != null) {
sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}");
@ -63,7 +63,7 @@ public class HighMemberPayPasswordSqlProvider {
return sql.toString();
}
public String selectByExample(HighMemberPayPasswordExample example) {
public String selectByExample(HighUserPayPasswordExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
@ -78,7 +78,7 @@ public class HighMemberPayPasswordSqlProvider {
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
sql.FROM("high_member_pay_password");
sql.FROM("high_user_pay_password");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
@ -89,11 +89,11 @@ public class HighMemberPayPasswordSqlProvider {
}
public String updateByExampleSelective(Map<String, Object> parameter) {
HighMemberPayPassword record = (HighMemberPayPassword) parameter.get("record");
HighMemberPayPasswordExample example = (HighMemberPayPasswordExample) parameter.get("example");
HighUserPayPassword record = (HighUserPayPassword) parameter.get("record");
HighUserPayPasswordExample example = (HighUserPayPasswordExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("high_member_pay_password");
sql.UPDATE("high_user_pay_password");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
@ -137,7 +137,7 @@ public class HighMemberPayPasswordSqlProvider {
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("high_member_pay_password");
sql.UPDATE("high_user_pay_password");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
@ -149,14 +149,14 @@ public class HighMemberPayPasswordSqlProvider {
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
HighMemberPayPasswordExample example = (HighMemberPayPasswordExample) parameter.get("example");
HighUserPayPasswordExample example = (HighUserPayPasswordExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(HighMemberPayPassword record) {
public String updateByPrimaryKeySelective(HighUserPayPassword record) {
SQL sql = new SQL();
sql.UPDATE("high_member_pay_password");
sql.UPDATE("high_user_pay_password");
if (record.getUserId() != null) {
sql.SET("user_id = #{userId,jdbcType=BIGINT}");
@ -195,7 +195,7 @@ public class HighMemberPayPasswordSqlProvider {
return sql.toString();
}
protected void applyWhere(SQL sql, HighMemberPayPasswordExample example, boolean includeExamplePhrase) {
protected void applyWhere(SQL sql, HighUserPayPasswordExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}

@ -4,7 +4,7 @@ import java.io.Serializable;
import java.util.Date;
/**
* high_member_pay_password
* high_user_pay_password
* @author
*/
/**
@ -12,7 +12,7 @@ import java.util.Date;
* 代码由工具生成
*
**/
public class HighMemberPayPassword implements Serializable {
public class HighUserPayPassword implements Serializable {
/**
* 支付密码编号
*/
@ -134,7 +134,7 @@ public class HighMemberPayPassword implements Serializable {
if (getClass() != that.getClass()) {
return false;
}
HighMemberPayPassword other = (HighMemberPayPassword) that;
HighUserPayPassword other = (HighUserPayPassword) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone()))

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class HighMemberPayPasswordExample {
public class HighUserPayPasswordExample {
protected String orderByClause;
protected boolean distinct;
@ -15,7 +15,7 @@ public class HighMemberPayPasswordExample {
private Long offset;
public HighMemberPayPasswordExample() {
public HighUserPayPasswordExample() {
oredCriteria = new ArrayList<Criteria>();
}

@ -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…
Cancel
Save