From e492ea590dec89db8908b82d1f4a27162241cdd5 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Tue, 9 Mar 2021 19:17:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?'=E5=AE=8C=E6=88=90=E5=95=86=E6=88=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighMerchantController.java | 132 ++++++++++++++++++ .../com/hai/common/exception/ErrorCode.java | 3 +- .../com/hai/common/security/UserCenter.java | 33 ++--- .../dao/HighMemberPayPasswordMapperExt.java | 7 - ...er.java => HighUserPayPasswordMapper.java} | 48 +++---- .../hai/dao/HighUserPayPasswordMapperExt.java | 7 + ...va => HighUserPayPasswordSqlProvider.java} | 42 +++--- ...Password.java => HighUserPayPassword.java} | 6 +- ...e.java => HighUserPayPasswordExample.java} | 4 +- .../com/hai/service/HighMerchantService.java | 32 +++++ .../com/hai/service/HighStoreService.java | 4 + .../service/impl/HighMerchantServiceImpl.java | 59 ++++++++ .../service/impl/HighStoreServiceImpl.java | 5 + 13 files changed, 305 insertions(+), 77 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java delete mode 100644 hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapperExt.java rename hai-service/src/main/java/com/hai/dao/{HighMemberPayPasswordMapper.java => HighUserPayPasswordMapper.java} (66%) create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapperExt.java rename hai-service/src/main/java/com/hai/dao/{HighMemberPayPasswordSqlProvider.java => HighUserPayPasswordSqlProvider.java} (87%) rename hai-service/src/main/java/com/hai/entity/{HighMemberPayPassword.java => HighUserPayPassword.java} (96%) rename hai-service/src/main/java/com/hai/entity/{HighMemberPayPasswordExample.java => HighUserPayPasswordExample.java} (99%) create mode 100644 hai-service/src/main/java/com/hai/service/HighMerchantService.java create mode 100644 hai-service/src/main/java/com/hai/service/HighStoreService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java new file mode 100644 index 00000000..9bd63c36 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.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 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); + } + } +} diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index 519c29f0..ae6faf1e 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -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处理异常"), diff --git a/hai-service/src/main/java/com/hai/common/security/UserCenter.java b/hai-service/src/main/java/com/hai/common/security/UserCenter.java index d3d6c78b..fb117a76 100644 --- a/hai-service/src/main/java/com/hai/common/security/UserCenter.java +++ b/hai-service/src/main/java/com/hai/common/security/UserCenter.java @@ -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 diff --git a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapperExt.java deleted file mode 100644 index 57868710..00000000 --- a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapperExt.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.hai.dao; - -/** - * mapper扩展类 - */ -public interface HighMemberPayPasswordMapperExt { -} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapper.java similarity index 66% rename from hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapper.java rename to hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapper.java index e4fe9e88..2500864e 100644 --- a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapper.java @@ -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 selectByExample(HighMemberPayPasswordExample example); + List 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); } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapperExt.java new file mode 100644 index 00000000..f4a6a7ac --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordMapperExt.java @@ -0,0 +1,7 @@ +package com.hai.dao; + +/** + * mapper扩展类 + */ +public interface HighUserPayPasswordMapperExt { +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordSqlProvider.java similarity index 87% rename from hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordSqlProvider.java rename to hai-service/src/main/java/com/hai/dao/HighUserPayPasswordSqlProvider.java index 033f6561..8d3c0c9b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighMemberPayPasswordSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserPayPasswordSqlProvider.java @@ -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 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 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; } diff --git a/hai-service/src/main/java/com/hai/entity/HighMemberPayPassword.java b/hai-service/src/main/java/com/hai/entity/HighUserPayPassword.java similarity index 96% rename from hai-service/src/main/java/com/hai/entity/HighMemberPayPassword.java rename to hai-service/src/main/java/com/hai/entity/HighUserPayPassword.java index 9085f3ac..5c62d8cf 100644 --- a/hai-service/src/main/java/com/hai/entity/HighMemberPayPassword.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserPayPassword.java @@ -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())) diff --git a/hai-service/src/main/java/com/hai/entity/HighMemberPayPasswordExample.java b/hai-service/src/main/java/com/hai/entity/HighUserPayPasswordExample.java similarity index 99% rename from hai-service/src/main/java/com/hai/entity/HighMemberPayPasswordExample.java rename to hai-service/src/main/java/com/hai/entity/HighUserPayPasswordExample.java index 9a63da0f..461b293a 100644 --- a/hai-service/src/main/java/com/hai/entity/HighMemberPayPasswordExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserPayPasswordExample.java @@ -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(); } diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantService.java b/hai-service/src/main/java/com/hai/service/HighMerchantService.java new file mode 100644 index 00000000..955494a1 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighMerchantService.java @@ -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 getMerchantList(Map map); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighStoreService.java b/hai-service/src/main/java/com/hai/service/HighStoreService.java new file mode 100644 index 00000000..2edd8d0b --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighStoreService.java @@ -0,0 +1,4 @@ +package com.hai.service; + +public interface HighStoreService { +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java new file mode 100644 index 00000000..00793907 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java @@ -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 getMerchantList(Map 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); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java new file mode 100644 index 00000000..a2b6ceb6 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java @@ -0,0 +1,5 @@ +package com.hai.service.impl; + + +public class HighStoreServiceImpl { +} From 7d49ac94c391d3d94340fffda66e5c4ae33d5cdc Mon Sep 17 00:00:00 2001 From: 199901012 Date: Tue, 9 Mar 2021 21:55:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?'=E5=AE=8C=E6=88=90=E5=95=86=E6=88=B7?= =?UTF-8?q?=E3=80=81=E5=95=86=E6=88=B7=E9=97=A8=E5=BA=97'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighMerchantController.java | 19 +- .../HighMerchantStoreController.java | 196 ++++++++++++++++++ .../com/hai/common/exception/ErrorCode.java | 2 + ...pper.java => HighMerchantStoreMapper.java} | 48 ++--- ...t.java => HighMerchantStoreMapperExt.java} | 2 +- ...java => HighMerchantStoreSqlProvider.java} | 42 ++-- ...{HighStore.java => HighMerchantStore.java} | 8 +- ...ple.java => HighMerchantStoreExample.java} | 4 +- .../java/com/hai/model/UserInfoModel.java | 10 + .../hai/service/HighMerchantStoreService.java | 36 ++++ .../com/hai/service/HighStoreService.java | 4 - .../service/impl/HighMerchantServiceImpl.java | 4 +- .../impl/HighMerchantStoreServiceImpl.java | 64 ++++++ .../service/impl/HighStoreServiceImpl.java | 5 - 14 files changed, 374 insertions(+), 70 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java rename hai-service/src/main/java/com/hai/dao/{HighStoreMapper.java => HighMerchantStoreMapper.java} (77%) rename hai-service/src/main/java/com/hai/dao/{HighStoreMapperExt.java => HighMerchantStoreMapperExt.java} (51%) rename hai-service/src/main/java/com/hai/dao/{HighStoreSqlProvider.java => HighMerchantStoreSqlProvider.java} (91%) rename hai-service/src/main/java/com/hai/entity/{HighStore.java => HighMerchantStore.java} (97%) rename hai-service/src/main/java/com/hai/entity/{HighStoreExample.java => HighMerchantStoreExample.java} (99%) create mode 100644 hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java delete mode 100644 hai-service/src/main/java/com/hai/service/HighStoreService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java delete mode 100644 hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java index 9bd63c36..f74db933 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java @@ -56,7 +56,6 @@ public class HighMerchantController { @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 @@ -108,15 +107,21 @@ public class HighMerchantController { @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, + public ResponseData getMerchantList(@RequestParam(name = "merchantKey", required = false) String merchantKey, + @RequestParam(name = "merchantName", required = false) String merchantName, + @RequestParam(name = "telephone", required = false) String telephone, @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { + @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("HighMerchantController -> getMerchantList() error!","权限不足"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } Map map = new HashMap<>(); - map.put("companyId", companyId); + map.put("companyId", userInfoModel.getBsCompany().getId()); map.put("merchantKey", merchantKey); map.put("merchantName", merchantName); map.put("telephone", telephone); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java new file mode 100644 index 00000000..2d4f4768 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java @@ -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 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 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); + } + } + + +} diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index ae6faf1e..fc048b75 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -75,11 +75,13 @@ public enum ErrorCode { SMS_CODE_ERROR("2103","验证码错误"), ID_CARD_NUM_IS_ERROR("2104","身份证号码错误"), MERCHANT_NOF_FOUND("2105","未找到商户"), + MERCHANT_STORE_NOF_FOUND("2106","未找到商户门店"), STATUS_ERROR("3000","状态错误"), ADD_DATA_ERROR("3001","增加数据失败"), UPDATE_DATA_ERROR("3002","修改数据失败"), DELETE_DATA_ERROR("3003","删除数据失败"), + COMPETENCE_INSUFFICIENT("3004","权限不足"), MSG_EVENT_NULL("2999","消息类型为空"), USE_VISIT_ILLEGAL("4001","用户身份错误"), diff --git a/hai-service/src/main/java/com/hai/dao/HighStoreMapper.java b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapper.java similarity index 77% rename from hai-service/src/main/java/com/hai/dao/HighStoreMapper.java rename to hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapper.java index 5c593c93..41adbab1 100644 --- a/hai-service/src/main/java/com/hai/dao/HighStoreMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapper.java @@ -1,7 +1,7 @@ package com.hai.dao; -import com.hai.entity.HighStore; -import com.hai.entity.HighStoreExample; +import com.hai.entity.HighMerchantStore; +import com.hai.entity.HighMerchantStoreExample; 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 HighStoreMapper extends HighStoreMapperExt { - @SelectProvider(type=HighStoreSqlProvider.class, method="countByExample") - long countByExample(HighStoreExample example); +public interface HighMerchantStoreMapper extends HighMerchantStoreMapperExt { + @SelectProvider(type=HighMerchantStoreSqlProvider.class, method="countByExample") + long countByExample(HighMerchantStoreExample example); - @DeleteProvider(type=HighStoreSqlProvider.class, method="deleteByExample") - int deleteByExample(HighStoreExample example); + @DeleteProvider(type=HighMerchantStoreSqlProvider.class, method="deleteByExample") + int deleteByExample(HighMerchantStoreExample example); @Delete({ - "delete from high_store", + "delete from high_merchant_store", "where id = #{id,jdbcType=BIGINT}" }) int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_store (company_id, merchant_id, ", + "insert into high_merchant_store (company_id, merchant_id, ", "store_key, store_name, ", "store_desc, telephone, ", "address, `status`, ", @@ -55,13 +55,13 @@ public interface HighStoreMapper extends HighStoreMapperExt { "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") - int insert(HighStore record); + int insert(HighMerchantStore record); - @InsertProvider(type=HighStoreSqlProvider.class, method="insertSelective") + @InsertProvider(type=HighMerchantStoreSqlProvider.class, method="insertSelective") @Options(useGeneratedKeys=true,keyProperty="id") - int insertSelective(HighStore record); + int insertSelective(HighMerchantStore record); - @SelectProvider(type=HighStoreSqlProvider.class, method="selectByExample") + @SelectProvider(type=HighMerchantStoreSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @@ -80,14 +80,14 @@ public interface HighStoreMapper extends HighStoreMapperExt { @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) - List selectByExample(HighStoreExample example); + List selectByExample(HighMerchantStoreExample example); @Select({ "select", "id, company_id, merchant_id, store_key, store_name, store_desc, telephone, address, ", "`status`, operator_id, operator_name, update_time, create_time, ext_1, ext_2, ", "ext_3", - "from high_store", + "from high_merchant_store", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @@ -108,19 +108,19 @@ public interface HighStoreMapper extends HighStoreMapperExt { @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) - HighStore selectByPrimaryKey(Long id); + HighMerchantStore selectByPrimaryKey(Long id); - @UpdateProvider(type=HighStoreSqlProvider.class, method="updateByExampleSelective") - int updateByExampleSelective(@Param("record") HighStore record, @Param("example") HighStoreExample example); + @UpdateProvider(type=HighMerchantStoreSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") HighMerchantStore record, @Param("example") HighMerchantStoreExample example); - @UpdateProvider(type=HighStoreSqlProvider.class, method="updateByExample") - int updateByExample(@Param("record") HighStore record, @Param("example") HighStoreExample example); + @UpdateProvider(type=HighMerchantStoreSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") HighMerchantStore record, @Param("example") HighMerchantStoreExample example); - @UpdateProvider(type=HighStoreSqlProvider.class, method="updateByPrimaryKeySelective") - int updateByPrimaryKeySelective(HighStore record); + @UpdateProvider(type=HighMerchantStoreSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighMerchantStore record); @Update({ - "update high_store", + "update high_merchant_store", "set company_id = #{companyId,jdbcType=BIGINT},", "merchant_id = #{merchantId,jdbcType=BIGINT},", "store_key = #{storeKey,jdbcType=VARCHAR},", @@ -138,5 +138,5 @@ public interface HighStoreMapper extends HighStoreMapperExt { "ext_3 = #{ext3,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}" }) - int updateByPrimaryKey(HighStore record); + int updateByPrimaryKey(HighMerchantStore record); } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighStoreMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapperExt.java similarity index 51% rename from hai-service/src/main/java/com/hai/dao/HighStoreMapperExt.java rename to hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapperExt.java index 179da5be..877bb902 100644 --- a/hai-service/src/main/java/com/hai/dao/HighStoreMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreMapperExt.java @@ -3,5 +3,5 @@ package com.hai.dao; /** * mapper扩展类 */ -public interface HighStoreMapperExt { +public interface HighMerchantStoreMapperExt { } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighStoreSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreSqlProvider.java similarity index 91% rename from hai-service/src/main/java/com/hai/dao/HighStoreSqlProvider.java rename to hai-service/src/main/java/com/hai/dao/HighMerchantStoreSqlProvider.java index 90324bf1..094ee50a 100644 --- a/hai-service/src/main/java/com/hai/dao/HighStoreSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantStoreSqlProvider.java @@ -1,32 +1,32 @@ package com.hai.dao; -import com.hai.entity.HighStore; -import com.hai.entity.HighStoreExample.Criteria; -import com.hai.entity.HighStoreExample.Criterion; -import com.hai.entity.HighStoreExample; +import com.hai.entity.HighMerchantStore; +import com.hai.entity.HighMerchantStoreExample.Criteria; +import com.hai.entity.HighMerchantStoreExample.Criterion; +import com.hai.entity.HighMerchantStoreExample; import java.util.List; import java.util.Map; import org.apache.ibatis.jdbc.SQL; -public class HighStoreSqlProvider { +public class HighMerchantStoreSqlProvider { - public String countByExample(HighStoreExample example) { + public String countByExample(HighMerchantStoreExample example) { SQL sql = new SQL(); - sql.SELECT("count(*)").FROM("high_store"); + sql.SELECT("count(*)").FROM("high_merchant_store"); applyWhere(sql, example, false); return sql.toString(); } - public String deleteByExample(HighStoreExample example) { + public String deleteByExample(HighMerchantStoreExample example) { SQL sql = new SQL(); - sql.DELETE_FROM("high_store"); + sql.DELETE_FROM("high_merchant_store"); applyWhere(sql, example, false); return sql.toString(); } - public String insertSelective(HighStore record) { + public String insertSelective(HighMerchantStore record) { SQL sql = new SQL(); - sql.INSERT_INTO("high_store"); + sql.INSERT_INTO("high_merchant_store"); if (record.getCompanyId() != null) { sql.VALUES("company_id", "#{companyId,jdbcType=BIGINT}"); @@ -91,7 +91,7 @@ public class HighStoreSqlProvider { return sql.toString(); } - public String selectByExample(HighStoreExample example) { + public String selectByExample(HighMerchantStoreExample example) { SQL sql = new SQL(); if (example != null && example.isDistinct()) { sql.SELECT_DISTINCT("id"); @@ -113,7 +113,7 @@ public class HighStoreSqlProvider { sql.SELECT("ext_1"); sql.SELECT("ext_2"); sql.SELECT("ext_3"); - sql.FROM("high_store"); + sql.FROM("high_merchant_store"); applyWhere(sql, example, false); if (example != null && example.getOrderByClause() != null) { @@ -124,11 +124,11 @@ public class HighStoreSqlProvider { } public String updateByExampleSelective(Map parameter) { - HighStore record = (HighStore) parameter.get("record"); - HighStoreExample example = (HighStoreExample) parameter.get("example"); + HighMerchantStore record = (HighMerchantStore) parameter.get("record"); + HighMerchantStoreExample example = (HighMerchantStoreExample) parameter.get("example"); SQL sql = new SQL(); - sql.UPDATE("high_store"); + sql.UPDATE("high_merchant_store"); if (record.getId() != null) { sql.SET("id = #{record.id,jdbcType=BIGINT}"); @@ -200,7 +200,7 @@ public class HighStoreSqlProvider { public String updateByExample(Map parameter) { SQL sql = new SQL(); - sql.UPDATE("high_store"); + sql.UPDATE("high_merchant_store"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); @@ -219,14 +219,14 @@ public class HighStoreSqlProvider { sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); - HighStoreExample example = (HighStoreExample) parameter.get("example"); + HighMerchantStoreExample example = (HighMerchantStoreExample) parameter.get("example"); applyWhere(sql, example, true); return sql.toString(); } - public String updateByPrimaryKeySelective(HighStore record) { + public String updateByPrimaryKeySelective(HighMerchantStore record) { SQL sql = new SQL(); - sql.UPDATE("high_store"); + sql.UPDATE("high_merchant_store"); if (record.getCompanyId() != null) { sql.SET("company_id = #{companyId,jdbcType=BIGINT}"); @@ -293,7 +293,7 @@ public class HighStoreSqlProvider { return sql.toString(); } - protected void applyWhere(SQL sql, HighStoreExample example, boolean includeExamplePhrase) { + protected void applyWhere(SQL sql, HighMerchantStoreExample example, boolean includeExamplePhrase) { if (example == null) { return; } diff --git a/hai-service/src/main/java/com/hai/entity/HighStore.java b/hai-service/src/main/java/com/hai/entity/HighMerchantStore.java similarity index 97% rename from hai-service/src/main/java/com/hai/entity/HighStore.java rename to hai-service/src/main/java/com/hai/entity/HighMerchantStore.java index 52c8547a..aef4c02f 100644 --- a/hai-service/src/main/java/com/hai/entity/HighStore.java +++ b/hai-service/src/main/java/com/hai/entity/HighMerchantStore.java @@ -4,7 +4,7 @@ import java.io.Serializable; import java.util.Date; /** - * high_store + * high_merchant_store * @author */ /** @@ -12,7 +12,7 @@ import java.util.Date; * 代码由工具生成 * **/ -public class HighStore implements Serializable { +public class HighMerchantStore implements Serializable { /** * 主键 */ @@ -54,7 +54,7 @@ public class HighStore implements Serializable { private String address; /** - * 状态:0:不可用,1:可用 + * 状态:0:删除,1:正常 */ private Integer status; @@ -225,7 +225,7 @@ public class HighStore implements Serializable { if (getClass() != that.getClass()) { return false; } - HighStore other = (HighStore) that; + HighMerchantStore other = (HighMerchantStore) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) && (this.getMerchantId() == null ? other.getMerchantId() == null : this.getMerchantId().equals(other.getMerchantId())) diff --git a/hai-service/src/main/java/com/hai/entity/HighStoreExample.java b/hai-service/src/main/java/com/hai/entity/HighMerchantStoreExample.java similarity index 99% rename from hai-service/src/main/java/com/hai/entity/HighStoreExample.java rename to hai-service/src/main/java/com/hai/entity/HighMerchantStoreExample.java index 43748550..e6ab6d62 100644 --- a/hai-service/src/main/java/com/hai/entity/HighStoreExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighMerchantStoreExample.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -public class HighStoreExample { +public class HighMerchantStoreExample { protected String orderByClause; protected boolean distinct; @@ -15,7 +15,7 @@ public class HighStoreExample { private Long offset; - public HighStoreExample() { + public HighMerchantStoreExample() { oredCriteria = new ArrayList(); } diff --git a/hai-service/src/main/java/com/hai/model/UserInfoModel.java b/hai-service/src/main/java/com/hai/model/UserInfoModel.java index 20b9f83f..628d0f16 100644 --- a/hai-service/src/main/java/com/hai/model/UserInfoModel.java +++ b/hai-service/src/main/java/com/hai/model/UserInfoModel.java @@ -24,6 +24,8 @@ public class UserInfoModel { private SecRole secRole; // 公司 private BsCompany bsCompany; + // 商户 + private HighMerchant merchant; // 权限列表 private List permissionList; // 菜单权限列表 @@ -33,6 +35,14 @@ public class UserInfoModel { private String token; + public HighMerchant getMerchant() { + return merchant; + } + + public void setMerchant(HighMerchant merchant) { + this.merchant = merchant; + } + public SecUser getSecUser() { return secUser; } diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java new file mode 100644 index 00000000..e83f4599 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java @@ -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 getMerchantStoreList(Map map); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighStoreService.java b/hai-service/src/main/java/com/hai/service/HighStoreService.java deleted file mode 100644 index 2edd8d0b..00000000 --- a/hai-service/src/main/java/com/hai/service/HighStoreService.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.hai.service; - -public interface HighStoreService { -} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java index 00793907..93fe1f8d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java @@ -37,11 +37,11 @@ public class HighMerchantServiceImpl implements HighMerchantService { HighMerchantExample example = new HighMerchantExample(); HighMerchantExample.Criteria criteria = example.createCriteria(); - if (map.get("companyId") != null) { + if (MapUtils.getLong(map, "companyId") != null) { criteria.andCompanyIdEqualTo(MapUtils.getLongValue(map, "companyId")); } - if (map.get("merchantKey") != null) { + if (MapUtils.getLong(map, "merchantKey") != null) { criteria.andMerchantKeyEqualTo(MapUtils.getString(map, "merchantKey")); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java new file mode 100644 index 00000000..28d8fccd --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -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 getMerchantStoreList(Map 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); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java deleted file mode 100644 index a2b6ceb6..00000000 --- a/hai-service/src/main/java/com/hai/service/impl/HighStoreServiceImpl.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.hai.service.impl; - - -public class HighStoreServiceImpl { -}