parent
703fc8ca5c
commit
d3deb2e608
@ -0,0 +1,132 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.model.BsMerModel; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.BsMerService; |
||||
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.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsMerController |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value="/mer") |
||||
@Api(value="商户业务") |
||||
public class BsMerController { |
||||
Logger log = LoggerFactory.getLogger(BsMerController.class); |
||||
@Resource |
||||
private BsMerService merService; |
||||
|
||||
@RequestMapping(value="/create",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "创建商户") |
||||
public ResponseData create(@RequestBody BsMerModel body) { |
||||
try { |
||||
if (body == null |
||||
|| StringUtils.isBlank(body.getLoginName()) |
||||
|| body.getRoleId() == null |
||||
|| StringUtils.isBlank(body.getMerName()) |
||||
|| StringUtils.isBlank(body.getDirectorName()) |
||||
|| StringUtils.isBlank(body.getDirectorTel()) |
||||
|| StringUtils.isBlank(body.getAddress()) |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
merService.create(body); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/update",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "修改商户") |
||||
public ResponseData update(@RequestBody BsMerModel body) { |
||||
try { |
||||
if (body == null |
||||
|| StringUtils.isBlank(body.getMerNo()) |
||||
|| body.getRoleId() == null |
||||
|| StringUtils.isBlank(body.getMerName()) |
||||
|| StringUtils.isBlank(body.getDirectorName()) |
||||
|| StringUtils.isBlank(body.getDirectorTel()) |
||||
|| StringUtils.isBlank(body.getAddress()) |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询商户
|
||||
if (merService.getDetail(body.getMerNo()) == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户不存在"); |
||||
} |
||||
|
||||
merService.update(body); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryMer",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询商户") |
||||
public ResponseData queryMer(@RequestParam(value = "merNo" , required = true) String merNo) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(merService.getDetail(merNo)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询商户列表") |
||||
public ResponseData queryList(@RequestParam(value = "merNo" , required = false) String merNo, |
||||
@RequestParam(value = "merName" , required = false) String merName, |
||||
@RequestParam(value = "status" , required = false) Integer status, |
||||
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize" , required = true) Integer pageSize) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("merNo", merNo); |
||||
param.put("merName", merName); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(merService.getList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -1,18 +1,49 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.SecDictionaryService; |
||||
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.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
@RestController |
||||
@Controller |
||||
@RequestMapping(value="/common") |
||||
@Api(value="共用接口") |
||||
public class CommonController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(CommonController.class); |
||||
@Resource |
||||
private SecDictionaryService secDictionaryService; |
||||
|
||||
@RequestMapping(value="/queryDictionary",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询数据字典") |
||||
public ResponseData queryDictionary(@RequestParam(value = "codeType" , required = false) String codeType, |
||||
@RequestParam(value = "codeValue" , required = false) String codeValue) { |
||||
try { |
||||
|
||||
if (StringUtils.isBlank(codeType) && StringUtils.isBlank(codeValue)) { |
||||
return ResponseMsgUtil.success(secDictionaryService.getDictionary()); |
||||
|
||||
} else if (StringUtils.isNotBlank(codeType) && StringUtils.isNotBlank(codeValue)) { |
||||
return ResponseMsgUtil.success(secDictionaryService.getDictionary(codeType, codeValue)); |
||||
|
||||
} else if (StringUtils.isNotBlank(codeType)) { |
||||
return ResponseMsgUtil.success(secDictionaryService.getDictionary(codeType)); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(null); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -1,99 +0,0 @@ |
||||
package com.hfkj.common.utils; |
||||
|
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
/** |
||||
* @ClassName IdCardUtil |
||||
* @Description |
||||
* @Author 杜江 |
||||
* @Date 2020/8/11 11:38 |
||||
* @Version 1.0 |
||||
*/ |
||||
public class IdCardUtil { |
||||
public static boolean isIdCard(String card){ |
||||
card = replaceBlank(card); |
||||
if(card == null || "".equals(card)){ |
||||
return false; |
||||
} |
||||
//定义 叛别用户 身份证号的正则表达式 (15位 或 18位,最后一位可以为字母)
|
||||
String requal = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|(10|20|30|31))\\d{3}[0-9Xx]$)|" |
||||
+"(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)"; |
||||
|
||||
// 假设18位 身份证号码:
|
||||
// ^ 表示开头
|
||||
// [1-9] 第一位1-9 中的一个 4 注意!! 前六位代表地址,此处是 拆分 讲解 对正则 的注释
|
||||
// \\d{5} 五位数字 10001(前六位省市县地区)
|
||||
// (18|19|20) 19 (现阶段可能取值范围18xx-20xx年)
|
||||
// \\d{2} 91 (年份)
|
||||
// ((0[1-9])|(10|11|12)) 01(月份)
|
||||
// (([0-2][1-9])|10|20|30|31) 01(日期) 也可写成(([0-2][1-9])|(10|20|30|31))
|
||||
// \\d{3} 三位数字 123(第十七位奇数表示男,偶数表示女)
|
||||
// [0-9Xx] 0123456789Xx 其中的一个 X(第十八位为校验值)
|
||||
// $结尾
|
||||
|
||||
// 假设15位身份证号码: 410001910101123
|
||||
// ^ 开头
|
||||
// [1-9] 第一位1-9中的一个 4
|
||||
// \\d{5} 五位数字 10001(前六位省市县地区)
|
||||
// \\d{2} 91(年份) 表示 91年
|
||||
// ((0[1-9])|(10|11|12)) 01(月份)
|
||||
// (([0-2][1-9])|10|20|30|31) 01(日期)
|
||||
// \\d{3} 123(第十五位奇数代表男,偶数代表女),15位身份证不含X
|
||||
// $结尾
|
||||
boolean matches = card.matches(requal); |
||||
|
||||
//判断 第 18位 校验值 ,校验算法涉及两次mod 11的过程
|
||||
// 二代身份证中的 号码第十八位的计算方法为:
|
||||
if(matches){ |
||||
if (card.length() == 18){ |
||||
try { |
||||
char[] charArray = card.toCharArray(); |
||||
//1,将前面的身份证号码17位数分别乘以不同的系数,系数为此处的 加权因子
|
||||
//前十七位加权因子
|
||||
int[] idCardWi = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; |
||||
int sum = 0; |
||||
// 2,将这17位数字 和系数相乘 的结果相加
|
||||
for (int i = 0;i < idCardWi.length;i++){ |
||||
int current = Integer.parseInt(String.valueOf(charArray[i])); |
||||
// 相乘对应的 加权因子系数
|
||||
int count = current * idCardWi[i]; |
||||
// 结果相加
|
||||
sum += count; |
||||
} |
||||
char idCardLast = charArray[17]; |
||||
// 3,结果和 除以11,查看余数
|
||||
int idCardMod = sum % 11; |
||||
// 4,这是除以 11后,可能产生的 11位余数对应的验证码(--对应下标),其中 X 代表罗马数字 10
|
||||
String[] idCardY = {"1","0","X","9","8","7","6","5","4","3","2"}; |
||||
if (idCardY[idCardMod].toUpperCase().equals(String.valueOf(idCardLast).toUpperCase())){ |
||||
return true; |
||||
}else { |
||||
System.out.println("身份证最后一位:"+String.valueOf(idCardLast).toUpperCase()+ |
||||
"错误,正确的应该是:"+idCardY[idCardMod].toUpperCase()); |
||||
return false; |
||||
} |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
System.out.println("异常:"+card); |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return matches; |
||||
} |
||||
|
||||
public static String replaceBlank(String str) { |
||||
String dest = ""; |
||||
if (str!=null) { |
||||
Pattern p = Pattern.compile("\\s*|\t|\r|\n"); |
||||
Matcher m = p.matcher(str); |
||||
dest = m.replaceAll(""); |
||||
} |
||||
return dest; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
System.out.println(isIdCard("5113221999409035038")); |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.hfkj.common.utils; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* |
||||
* @className: RandomUtils |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
public class RandomUtils { |
||||
|
||||
/** |
||||
* 生成随机数 |
||||
* @param length 长度 |
||||
* @param zero 是否包含零 |
||||
* @return |
||||
*/ |
||||
public static String number(int length, boolean zero) { |
||||
String sl = "123456789"; |
||||
if (zero) { |
||||
sl += "0"; |
||||
} |
||||
StringBuilder sb = new StringBuilder(); |
||||
for(int i = 0 ; i < length ; i ++){ |
||||
sb.append(sl.charAt(new Random().nextInt(sl.length()))); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,133 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsMer; |
||||
import com.hfkj.entity.BsMerExample; |
||||
import java.util.List; |
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.DeleteProvider; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.InsertProvider; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Result; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.SelectProvider; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.annotations.UpdateProvider; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
/** |
||||
* |
||||
* 代码由工具生成,请勿修改!!! |
||||
* 如果需要扩展请在其父类进行扩展 |
||||
* |
||||
**/ |
||||
@Repository |
||||
public interface BsMerMapper extends BsMerMapperExt { |
||||
@SelectProvider(type=BsMerSqlProvider.class, method="countByExample") |
||||
long countByExample(BsMerExample example); |
||||
|
||||
@DeleteProvider(type=BsMerSqlProvider.class, method="deleteByExample") |
||||
int deleteByExample(BsMerExample example); |
||||
|
||||
@Delete({ |
||||
"delete from bs_mer", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
@Insert({ |
||||
"insert into bs_mer (mer_no, mer_logo, ", |
||||
"mer_name, director_name, ", |
||||
"director_tel, customer_service_tel, ", |
||||
"address, `status`, ", |
||||
"create_time, update_time, ", |
||||
"ext_1, ext_2, ext_3)", |
||||
"values (#{merNo,jdbcType=VARCHAR}, #{merLogo,jdbcType=VARCHAR}, ", |
||||
"#{merName,jdbcType=VARCHAR}, #{directorName,jdbcType=VARCHAR}, ", |
||||
"#{directorTel,jdbcType=VARCHAR}, #{customerServiceTel,jdbcType=VARCHAR}, ", |
||||
"#{address,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", |
||||
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", |
||||
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" |
||||
}) |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insert(BsMer record); |
||||
|
||||
@InsertProvider(type=BsMerSqlProvider.class, method="insertSelective") |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insertSelective(BsMer record); |
||||
|
||||
@SelectProvider(type=BsMerSqlProvider.class, method="selectByExample") |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_logo", property="merLogo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="director_name", property="directorName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="director_tel", property="directorTel", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="customer_service_tel", property="customerServiceTel", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="address", property="address", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
List<BsMer> selectByExample(BsMerExample example); |
||||
|
||||
@Select({ |
||||
"select", |
||||
"id, mer_no, mer_logo, mer_name, director_name, director_tel, customer_service_tel, ", |
||||
"address, `status`, create_time, update_time, ext_1, ext_2, ext_3", |
||||
"from bs_mer", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_logo", property="merLogo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="director_name", property="directorName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="director_tel", property="directorTel", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="customer_service_tel", property="customerServiceTel", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="address", property="address", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
BsMer selectByPrimaryKey(Long id); |
||||
|
||||
@UpdateProvider(type=BsMerSqlProvider.class, method="updateByExampleSelective") |
||||
int updateByExampleSelective(@Param("record") BsMer record, @Param("example") BsMerExample example); |
||||
|
||||
@UpdateProvider(type=BsMerSqlProvider.class, method="updateByExample") |
||||
int updateByExample(@Param("record") BsMer record, @Param("example") BsMerExample example); |
||||
|
||||
@UpdateProvider(type=BsMerSqlProvider.class, method="updateByPrimaryKeySelective") |
||||
int updateByPrimaryKeySelective(BsMer record); |
||||
|
||||
@Update({ |
||||
"update bs_mer", |
||||
"set mer_no = #{merNo,jdbcType=VARCHAR},", |
||||
"mer_logo = #{merLogo,jdbcType=VARCHAR},", |
||||
"mer_name = #{merName,jdbcType=VARCHAR},", |
||||
"director_name = #{directorName,jdbcType=VARCHAR},", |
||||
"director_tel = #{directorTel,jdbcType=VARCHAR},", |
||||
"customer_service_tel = #{customerServiceTel,jdbcType=VARCHAR},", |
||||
"address = #{address,jdbcType=VARCHAR},", |
||||
"`status` = #{status,jdbcType=INTEGER},", |
||||
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||
"update_time = #{updateTime,jdbcType=TIMESTAMP},", |
||||
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int updateByPrimaryKey(BsMer record); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsMerMapperExt { |
||||
} |
@ -0,0 +1,360 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsMer; |
||||
import com.hfkj.entity.BsMerExample.Criteria; |
||||
import com.hfkj.entity.BsMerExample.Criterion; |
||||
import com.hfkj.entity.BsMerExample; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import org.apache.ibatis.jdbc.SQL; |
||||
|
||||
public class BsMerSqlProvider { |
||||
|
||||
public String countByExample(BsMerExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.SELECT("count(*)").FROM("bs_mer"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String deleteByExample(BsMerExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.DELETE_FROM("bs_mer"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String insertSelective(BsMer record) { |
||||
SQL sql = new SQL(); |
||||
sql.INSERT_INTO("bs_mer"); |
||||
|
||||
if (record.getMerNo() != null) { |
||||
sql.VALUES("mer_no", "#{merNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerLogo() != null) { |
||||
sql.VALUES("mer_logo", "#{merLogo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.VALUES("mer_name", "#{merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorName() != null) { |
||||
sql.VALUES("director_name", "#{directorName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorTel() != null) { |
||||
sql.VALUES("director_tel", "#{directorTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCustomerServiceTel() != null) { |
||||
sql.VALUES("customer_service_tel", "#{customerServiceTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getAddress() != null) { |
||||
sql.VALUES("address", "#{address,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String selectByExample(BsMerExample example) { |
||||
SQL sql = new SQL(); |
||||
if (example != null && example.isDistinct()) { |
||||
sql.SELECT_DISTINCT("id"); |
||||
} else { |
||||
sql.SELECT("id"); |
||||
} |
||||
sql.SELECT("mer_no"); |
||||
sql.SELECT("mer_logo"); |
||||
sql.SELECT("mer_name"); |
||||
sql.SELECT("director_name"); |
||||
sql.SELECT("director_tel"); |
||||
sql.SELECT("customer_service_tel"); |
||||
sql.SELECT("address"); |
||||
sql.SELECT("`status`"); |
||||
sql.SELECT("create_time"); |
||||
sql.SELECT("update_time"); |
||||
sql.SELECT("ext_1"); |
||||
sql.SELECT("ext_2"); |
||||
sql.SELECT("ext_3"); |
||||
sql.FROM("bs_mer"); |
||||
applyWhere(sql, example, false); |
||||
|
||||
if (example != null && example.getOrderByClause() != null) { |
||||
sql.ORDER_BY(example.getOrderByClause()); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExampleSelective(Map<String, Object> parameter) { |
||||
BsMer record = (BsMer) parameter.get("record"); |
||||
BsMerExample example = (BsMerExample) parameter.get("example"); |
||||
|
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_mer"); |
||||
|
||||
if (record.getId() != null) { |
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerNo() != null) { |
||||
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerLogo() != null) { |
||||
sql.SET("mer_logo = #{record.merLogo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorName() != null) { |
||||
sql.SET("director_name = #{record.directorName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorTel() != null) { |
||||
sql.SET("director_tel = #{record.directorTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCustomerServiceTel() != null) { |
||||
sql.SET("customer_service_tel = #{record.customerServiceTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getAddress() != null) { |
||||
sql.SET("address = #{record.address,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExample(Map<String, Object> parameter) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_mer"); |
||||
|
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}"); |
||||
sql.SET("mer_logo = #{record.merLogo,jdbcType=VARCHAR}"); |
||||
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); |
||||
sql.SET("director_name = #{record.directorName,jdbcType=VARCHAR}"); |
||||
sql.SET("director_tel = #{record.directorTel,jdbcType=VARCHAR}"); |
||||
sql.SET("customer_service_tel = #{record.customerServiceTel,jdbcType=VARCHAR}"); |
||||
sql.SET("address = #{record.address,jdbcType=VARCHAR}"); |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
|
||||
BsMerExample example = (BsMerExample) parameter.get("example"); |
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByPrimaryKeySelective(BsMer record) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_mer"); |
||||
|
||||
if (record.getMerNo() != null) { |
||||
sql.SET("mer_no = #{merNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerLogo() != null) { |
||||
sql.SET("mer_logo = #{merLogo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.SET("mer_name = #{merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorName() != null) { |
||||
sql.SET("director_name = #{directorName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDirectorTel() != null) { |
||||
sql.SET("director_tel = #{directorTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCustomerServiceTel() != null) { |
||||
sql.SET("customer_service_tel = #{customerServiceTel,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getAddress() != null) { |
||||
sql.SET("address = #{address,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
sql.WHERE("id = #{id,jdbcType=BIGINT}"); |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
protected void applyWhere(SQL sql, BsMerExample example, boolean includeExamplePhrase) { |
||||
if (example == null) { |
||||
return; |
||||
} |
||||
|
||||
String parmPhrase1; |
||||
String parmPhrase1_th; |
||||
String parmPhrase2; |
||||
String parmPhrase2_th; |
||||
String parmPhrase3; |
||||
String parmPhrase3_th; |
||||
if (includeExamplePhrase) { |
||||
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} else { |
||||
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} |
||||
|
||||
StringBuilder sb = new StringBuilder(); |
||||
List<Criteria> oredCriteria = example.getOredCriteria(); |
||||
boolean firstCriteria = true; |
||||
for (int i = 0; i < oredCriteria.size(); i++) { |
||||
Criteria criteria = oredCriteria.get(i); |
||||
if (criteria.isValid()) { |
||||
if (firstCriteria) { |
||||
firstCriteria = false; |
||||
} else { |
||||
sb.append(" or "); |
||||
} |
||||
|
||||
sb.append('('); |
||||
List<Criterion> criterions = criteria.getAllCriteria(); |
||||
boolean firstCriterion = true; |
||||
for (int j = 0; j < criterions.size(); j++) { |
||||
Criterion criterion = criterions.get(j); |
||||
if (firstCriterion) { |
||||
firstCriterion = false; |
||||
} else { |
||||
sb.append(" and "); |
||||
} |
||||
|
||||
if (criterion.isNoValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
} else if (criterion.isSingleValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isBetweenValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isListValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
sb.append(" ("); |
||||
List<?> listItems = (List<?>) criterion.getValue(); |
||||
boolean comma = false; |
||||
for (int k = 0; k < listItems.size(); k++) { |
||||
if (comma) { |
||||
sb.append(", "); |
||||
} else { |
||||
comma = true; |
||||
} |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase3, i, j, k)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
|
||||
if (sb.length() > 0) { |
||||
sql.WHERE(sb.toString()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,264 @@ |
||||
package com.hfkj.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* bs_mer |
||||
* @author |
||||
*/ |
||||
/** |
||||
* |
||||
* 代码由工具生成 |
||||
* |
||||
**/ |
||||
public class BsMer implements Serializable { |
||||
/** |
||||
* 主键 |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 商户号 |
||||
*/ |
||||
private String merNo; |
||||
|
||||
/** |
||||
* 商户LOGO |
||||
*/ |
||||
private String merLogo; |
||||
|
||||
/** |
||||
* 商户名称 |
||||
*/ |
||||
private String merName; |
||||
|
||||
/** |
||||
* 负责人名称 |
||||
*/ |
||||
private String directorName; |
||||
|
||||
/** |
||||
* 负责人电话 |
||||
*/ |
||||
private String directorTel; |
||||
|
||||
/** |
||||
* 客服电话 |
||||
*/ |
||||
private String customerServiceTel; |
||||
|
||||
/** |
||||
* 详细地址 |
||||
*/ |
||||
private String address; |
||||
|
||||
/** |
||||
* 状态 0:不可用 1:正常 2:禁用 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 修改时间 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
private String ext1; |
||||
|
||||
private String ext2; |
||||
|
||||
private String ext3; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getMerNo() { |
||||
return merNo; |
||||
} |
||||
|
||||
public void setMerNo(String merNo) { |
||||
this.merNo = merNo; |
||||
} |
||||
|
||||
public String getMerLogo() { |
||||
return merLogo; |
||||
} |
||||
|
||||
public void setMerLogo(String merLogo) { |
||||
this.merLogo = merLogo; |
||||
} |
||||
|
||||
public String getMerName() { |
||||
return merName; |
||||
} |
||||
|
||||
public void setMerName(String merName) { |
||||
this.merName = merName; |
||||
} |
||||
|
||||
public String getDirectorName() { |
||||
return directorName; |
||||
} |
||||
|
||||
public void setDirectorName(String directorName) { |
||||
this.directorName = directorName; |
||||
} |
||||
|
||||
public String getDirectorTel() { |
||||
return directorTel; |
||||
} |
||||
|
||||
public void setDirectorTel(String directorTel) { |
||||
this.directorTel = directorTel; |
||||
} |
||||
|
||||
public String getCustomerServiceTel() { |
||||
return customerServiceTel; |
||||
} |
||||
|
||||
public void setCustomerServiceTel(String customerServiceTel) { |
||||
this.customerServiceTel = customerServiceTel; |
||||
} |
||||
|
||||
public String getAddress() { |
||||
return address; |
||||
} |
||||
|
||||
public void setAddress(String address) { |
||||
this.address = address; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getExt1() { |
||||
return ext1; |
||||
} |
||||
|
||||
public void setExt1(String ext1) { |
||||
this.ext1 = ext1; |
||||
} |
||||
|
||||
public String getExt2() { |
||||
return ext2; |
||||
} |
||||
|
||||
public void setExt2(String ext2) { |
||||
this.ext2 = ext2; |
||||
} |
||||
|
||||
public String getExt3() { |
||||
return ext3; |
||||
} |
||||
|
||||
public void setExt3(String ext3) { |
||||
this.ext3 = ext3; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object that) { |
||||
if (this == that) { |
||||
return true; |
||||
} |
||||
if (that == null) { |
||||
return false; |
||||
} |
||||
if (getClass() != that.getClass()) { |
||||
return false; |
||||
} |
||||
BsMer other = (BsMer) that; |
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||
&& (this.getMerNo() == null ? other.getMerNo() == null : this.getMerNo().equals(other.getMerNo())) |
||||
&& (this.getMerLogo() == null ? other.getMerLogo() == null : this.getMerLogo().equals(other.getMerLogo())) |
||||
&& (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName())) |
||||
&& (this.getDirectorName() == null ? other.getDirectorName() == null : this.getDirectorName().equals(other.getDirectorName())) |
||||
&& (this.getDirectorTel() == null ? other.getDirectorTel() == null : this.getDirectorTel().equals(other.getDirectorTel())) |
||||
&& (this.getCustomerServiceTel() == null ? other.getCustomerServiceTel() == null : this.getCustomerServiceTel().equals(other.getCustomerServiceTel())) |
||||
&& (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress())) |
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) |
||||
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) |
||||
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) |
||||
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
final int prime = 31; |
||||
int result = 1; |
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
||||
result = prime * result + ((getMerNo() == null) ? 0 : getMerNo().hashCode()); |
||||
result = prime * result + ((getMerLogo() == null) ? 0 : getMerLogo().hashCode()); |
||||
result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode()); |
||||
result = prime * result + ((getDirectorName() == null) ? 0 : getDirectorName().hashCode()); |
||||
result = prime * result + ((getDirectorTel() == null) ? 0 : getDirectorTel().hashCode()); |
||||
result = prime * result + ((getCustomerServiceTel() == null) ? 0 : getCustomerServiceTel().hashCode()); |
||||
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode()); |
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
||||
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); |
||||
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); |
||||
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(getClass().getSimpleName()); |
||||
sb.append(" ["); |
||||
sb.append("Hash = ").append(hashCode()); |
||||
sb.append(", id=").append(id); |
||||
sb.append(", merNo=").append(merNo); |
||||
sb.append(", merLogo=").append(merLogo); |
||||
sb.append(", merName=").append(merName); |
||||
sb.append(", directorName=").append(directorName); |
||||
sb.append(", directorTel=").append(directorTel); |
||||
sb.append(", customerServiceTel=").append(customerServiceTel); |
||||
sb.append(", address=").append(address); |
||||
sb.append(", status=").append(status); |
||||
sb.append(", createTime=").append(createTime); |
||||
sb.append(", updateTime=").append(updateTime); |
||||
sb.append(", ext1=").append(ext1); |
||||
sb.append(", ext2=").append(ext2); |
||||
sb.append(", ext3=").append(ext3); |
||||
sb.append(", serialVersionUID=").append(serialVersionUID); |
||||
sb.append("]"); |
||||
return sb.toString(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@ |
||||
package com.hfkj.model; |
||||
|
||||
import com.hfkj.entity.BsMer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* @className: BsMerModel |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@Data |
||||
public class BsMerModel extends BsMer { |
||||
|
||||
/** |
||||
* 登录账户 |
||||
*/ |
||||
private String loginName; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
private Long roleId; |
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.hfkj.service; |
||||
|
||||
import com.hfkj.entity.BsMer; |
||||
import com.hfkj.model.BsMerModel; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsMerService |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
public interface BsMerService { |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param mer |
||||
*/ |
||||
void editData(BsMer mer); |
||||
|
||||
/** |
||||
* 创建商户 |
||||
* @param mer |
||||
*/ |
||||
void create(BsMerModel mer) throws Exception; |
||||
|
||||
/** |
||||
* 修改商户 |
||||
* @param mer |
||||
*/ |
||||
void update(BsMerModel mer) throws Exception; |
||||
|
||||
/** |
||||
* 查询商户详情 |
||||
* @param merNo 商户号 |
||||
* @return |
||||
*/ |
||||
BsMerModel getDetail(String merNo); |
||||
|
||||
/** |
||||
* 查询商户列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<BsMer> getList(Map<String,Object> param); |
||||
|
||||
|
||||
} |
@ -0,0 +1,37 @@ |
||||
package com.hfkj.service; |
||||
|
||||
import com.hfkj.entity.SecDictionary; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @className: SecDictionaryService |
||||
* @author: HuRui |
||||
* @date: 2024/4/23 |
||||
**/ |
||||
public interface SecDictionaryService { |
||||
|
||||
/** |
||||
* 获取数据字典 |
||||
* @return |
||||
*/ |
||||
List<SecDictionary> getDictionary(); |
||||
|
||||
/** |
||||
* 获取数据字典 |
||||
* @param codeType |
||||
* @return |
||||
*/ |
||||
List<SecDictionary> getDictionary(String codeType); |
||||
|
||||
/** |
||||
* 获取数据字典 |
||||
* @param codeType |
||||
* @param codeValue |
||||
* @return |
||||
*/ |
||||
SecDictionary getDictionary(String codeType, String codeValue); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,160 @@ |
||||
package com.hfkj.service.impl; |
||||
|
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.MD5Util; |
||||
import com.hfkj.common.utils.RandomUtils; |
||||
import com.hfkj.common.utils.RedisUtil; |
||||
import com.hfkj.dao.BsMerMapper; |
||||
import com.hfkj.entity.BsMer; |
||||
import com.hfkj.entity.BsMerExample; |
||||
import com.hfkj.entity.SecUser; |
||||
import com.hfkj.model.BsMerModel; |
||||
import com.hfkj.service.BsMerService; |
||||
import com.hfkj.service.SecUserService; |
||||
import com.hfkj.sysenum.MerStatusEnum; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* @className: BsMerServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
@Service("merService") |
||||
public class BsMerServiceImpl implements BsMerService { |
||||
@Autowired |
||||
private RedisUtil redisUtil; |
||||
private final static String CACHE_MER_KEY = "MER:"; |
||||
@Resource |
||||
private BsMerMapper merMapper; |
||||
@Resource |
||||
private SecUserService secUserService; |
||||
|
||||
/** |
||||
* 生成商户号 |
||||
* @return |
||||
*/ |
||||
private static String generateMerNo() { |
||||
// 166 + 时间 + 随机3位数
|
||||
return "166"+DateUtil.format(new Date(), "yyHHmm") + RandomUtils.number(3, false); |
||||
} |
||||
|
||||
@Override |
||||
public void editData(BsMer mer) { |
||||
mer.setUpdateTime(new Date()); |
||||
if (mer.getId() == null) { |
||||
mer.setCreateTime(new Date()); |
||||
merMapper.insert(mer); |
||||
// 生成商户号
|
||||
mer.setMerNo(generateMerNo()); |
||||
if (getDetail(mer.getMerNo()) != null) { |
||||
editData(mer); |
||||
} |
||||
merMapper.updateByPrimaryKey(mer); |
||||
} else { |
||||
merMapper.updateByPrimaryKey(mer); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
||||
public void create(BsMerModel mer) throws Exception { |
||||
editData(mer); |
||||
|
||||
if (secUserService.getDetailByLoginName(mer.getLoginName()) != null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户已存在,请更换"); |
||||
} |
||||
|
||||
SecUser secUser = new SecUser(); |
||||
secUser.setUserName(mer.getMerName()); |
||||
secUser.setLoginName(mer.getLoginName()); |
||||
secUser.setPassword(MD5Util.encode("123456".getBytes())); |
||||
secUser.setTelephone(mer.getDirectorTel()); |
||||
secUser.setRoleId(mer.getRoleId()); |
||||
secUser.setObjectType(SecUserObjectTypeEnum.type2.getCode()); |
||||
secUser.setObjectId(mer.getId()); |
||||
secUserService.editUser(secUser); |
||||
|
||||
// 加入缓存
|
||||
redisUtil.set(CACHE_MER_KEY, mer); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
||||
public void update(BsMerModel mer) throws Exception { |
||||
editData(mer); |
||||
|
||||
// 查询账户
|
||||
SecUser secUser = secUserService.getDetail(SecUserObjectTypeEnum.type2, mer.getId()); |
||||
if (secUser == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户登录账户数据异常"); |
||||
} |
||||
secUser.setUserName(mer.getMerName()); |
||||
secUser.setTelephone(mer.getDirectorTel()); |
||||
secUser.setRoleId(mer.getRoleId()); |
||||
secUserService.editUser(secUser); |
||||
|
||||
// 加入缓存
|
||||
redisUtil.set(CACHE_MER_KEY, mer); |
||||
} |
||||
|
||||
@Override |
||||
public BsMerModel getDetail(String merNo) { |
||||
Object cacheObj = redisUtil.get(CACHE_MER_KEY); |
||||
if (cacheObj != null) { |
||||
return (BsMerModel) cacheObj; |
||||
} |
||||
BsMerExample example = new BsMerExample(); |
||||
example.createCriteria().andMerNoEqualTo(merNo).andStatusNotEqualTo(MerStatusEnum.status0.getCode()); |
||||
List<BsMer> list = merMapper.selectByExample(example); |
||||
if (!list.isEmpty()) { |
||||
BsMerModel mer = (BsMerModel)list.get(0); |
||||
// 查询账户
|
||||
SecUser secUser = secUserService.getDetail(SecUserObjectTypeEnum.type2, mer.getId()); |
||||
if (secUser != null) { |
||||
mer.setLoginName(secUser.getLoginName()); |
||||
} |
||||
redisUtil.set(CACHE_MER_KEY, mer); |
||||
return mer; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<BsMer> getList(Map<String, Object> param) { |
||||
BsMerExample example = new BsMerExample(); |
||||
BsMerExample.Criteria criteria = example.createCriteria() |
||||
.andStatusNotEqualTo(MerStatusEnum.status0.getCode()); |
||||
|
||||
if (StringUtils.isBlank(MapUtils.getString(param, "merNo"))) { |
||||
criteria.andMerNoLike("%"+MapUtils.getString(param, "merNo")+"%"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(MapUtils.getString(param, "merName"))) { |
||||
criteria.andMerNameLike("%"+MapUtils.getString(param, "merName")+"%"); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return merMapper.selectByExample(example); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,59 @@ |
||||
package com.hfkj.service.impl; |
||||
|
||||
import com.hfkj.common.utils.RedisUtil; |
||||
import com.hfkj.dao.SecDictionaryMapper; |
||||
import com.hfkj.entity.SecDictionary; |
||||
import com.hfkj.entity.SecDictionaryExample; |
||||
import com.hfkj.service.SecDictionaryService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @className: SecDictionaryServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2024/4/23 |
||||
**/ |
||||
@Service("secDictionaryService") |
||||
public class SecDictionaryServiceImpl implements SecDictionaryService { |
||||
|
||||
@Resource |
||||
private SecDictionaryMapper secDictionaryMapper; |
||||
@Resource |
||||
private RedisUtil redisUtil; |
||||
// 缓存KEY
|
||||
private final String cacheKey = "SEC_DICTIONARY"; |
||||
|
||||
@Override |
||||
public List<SecDictionary> getDictionary() { |
||||
Object cache = redisUtil.get(cacheKey); |
||||
if (cache != null) { |
||||
return (List<SecDictionary>) cache; |
||||
} |
||||
SecDictionaryExample example = new SecDictionaryExample(); |
||||
example.setOrderByClause("sort_id"); |
||||
List<SecDictionary> list = secDictionaryMapper.selectByExample(example); |
||||
redisUtil.set(cacheKey, list); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public List<SecDictionary> getDictionary(String codeType) { |
||||
return getDictionary().stream().filter(o -> o.getCodeType().equals(codeType)).collect(Collectors.toList()); |
||||
} |
||||
|
||||
@Override |
||||
public SecDictionary getDictionary(String codeType, String codeValue) { |
||||
List<SecDictionary> list = getDictionary().stream() |
||||
.filter(o -> o.getCodeType().equals(codeType) && o.getCodeValue().equals(codeValue)) |
||||
.collect(Collectors.toList()); |
||||
if (!list.isEmpty()) { |
||||
return list.get(0); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.hfkj.sysenum; |
||||
|
||||
/** |
||||
* 菜单类型 |
||||
* @className: MerStatusEnum |
||||
* @author: HuRui |
||||
* @date: 2024/4/24 |
||||
**/ |
||||
public enum MerStatusEnum { |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
status0(0, "删除"), |
||||
|
||||
/** |
||||
* 正常 |
||||
*/ |
||||
status1(1, "正常"), |
||||
; |
||||
|
||||
private int code; |
||||
|
||||
private String name; |
||||
|
||||
|
||||
MerStatusEnum(int code, String name) { |
||||
this.code = code; |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.hfkj.sysenum; |
||||
|
||||
/** |
||||
* 账户类型 |
||||
* @className: SecUserObjectTypeEnum |
||||
* @author: HuRui |
||||
* @date: 2024/4/23 |
||||
**/ |
||||
public enum SecUserObjectTypeEnum { |
||||
|
||||
/** |
||||
* 系统账户 |
||||
*/ |
||||
type1(1, "系统账户"), |
||||
|
||||
/** |
||||
* 商户 |
||||
*/ |
||||
type2(2, "商户"), |
||||
; |
||||
|
||||
private int code; |
||||
|
||||
private String name; |
||||
|
||||
|
||||
SecUserObjectTypeEnum(int code, String name) { |
||||
this.code = code; |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue