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 { -}