parent
12361207d4
commit
d3f57a533b
@ -0,0 +1,75 @@ |
|||||||
|
package com.cweb.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
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.utils.CoordCommonUtil; |
||||||
|
import com.hai.common.utils.PageUtil; |
||||||
|
import com.hai.common.utils.ResponseMsgUtil; |
||||||
|
import com.hai.config.CommonSysConst; |
||||||
|
import com.hai.config.TuanYouConfig; |
||||||
|
import com.hai.dao.HighGasOrderPushMapper; |
||||||
|
import com.hai.entity.*; |
||||||
|
import com.hai.enum_type.GasOilPriceStatusEnum; |
||||||
|
import com.hai.enum_type.MerchantStoreSourceType; |
||||||
|
import com.hai.model.HighMerchantStoreModel; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.service.*; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
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.math.BigDecimal; |
||||||
|
import java.util.*; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/gasOrder") |
||||||
|
@Api(value = "加油订单") |
||||||
|
public class HighGasOrderController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HighGasOrderController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighGasOrderService gasOrderService; |
||||||
|
|
||||||
|
@RequestMapping(value="/getOrderByOrderNo",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "根据订单号查询") |
||||||
|
public ResponseData getOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { |
||||||
|
try { |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo)); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighGasOrderController -> getOrderByOrderNo() error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/getOrderByChildOrderNo",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "根据子订单号查询") |
||||||
|
public ResponseData getOrderByChildOrderNo(@RequestParam(name = "childOrderNo", required = true) String childOrderNo) { |
||||||
|
try { |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(gasOrderService.getDetailByChildOrderNo(childOrderNo)); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighGasOrderController -> getOrderByChildOrderNo() error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.hai.common.utils; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
/** |
||||||
|
* 百度工具 |
||||||
|
* @className: BaiduUtis |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/10/21 |
||||||
|
**/ |
||||||
|
public class BaiduUtils { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(BaiduUtils.class); |
||||||
|
|
||||||
|
/** |
||||||
|
* IP 定位 |
||||||
|
* @param ip ip地址 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static JSONObject ipLocation(String ip) { |
||||||
|
JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip); |
||||||
|
log.info(response.toJSONString()); |
||||||
|
return response; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,128 @@ |
|||||||
|
package com.hai.dao; |
||||||
|
|
||||||
|
import com.hai.entity.HighUserLoginLog; |
||||||
|
import com.hai.entity.HighUserLoginLogExample; |
||||||
|
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 HighUserLoginLogMapper extends HighUserLoginLogMapperExt { |
||||||
|
@SelectProvider(type=HighUserLoginLogSqlProvider.class, method="countByExample") |
||||||
|
long countByExample(HighUserLoginLogExample example); |
||||||
|
|
||||||
|
@DeleteProvider(type=HighUserLoginLogSqlProvider.class, method="deleteByExample") |
||||||
|
int deleteByExample(HighUserLoginLogExample example); |
||||||
|
|
||||||
|
@Delete({ |
||||||
|
"delete from high_user_login_log", |
||||||
|
"where id = #{id,jdbcType=BIGINT}" |
||||||
|
}) |
||||||
|
int deleteByPrimaryKey(Long id); |
||||||
|
|
||||||
|
@Insert({ |
||||||
|
"insert into high_user_login_log (user_id, user_phone, ", |
||||||
|
"platform, ip, province_name, ", |
||||||
|
"city_code, city_name, ", |
||||||
|
"`status`, create_time, ", |
||||||
|
"ext_1, ext_2, ext_3)", |
||||||
|
"values (#{userId,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, ", |
||||||
|
"#{platform,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, ", |
||||||
|
"#{cityCode,jdbcType=VARCHAR}, #{cityName,jdbcType=VARCHAR}, ", |
||||||
|
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", |
||||||
|
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" |
||||||
|
}) |
||||||
|
@Options(useGeneratedKeys=true,keyProperty="id") |
||||||
|
int insert(HighUserLoginLog record); |
||||||
|
|
||||||
|
@InsertProvider(type=HighUserLoginLogSqlProvider.class, method="insertSelective") |
||||||
|
@Options(useGeneratedKeys=true,keyProperty="id") |
||||||
|
int insertSelective(HighUserLoginLog record); |
||||||
|
|
||||||
|
@SelectProvider(type=HighUserLoginLogSqlProvider.class, method="selectByExample") |
||||||
|
@Results({ |
||||||
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||||
|
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), |
||||||
|
@Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="create_time", property="createTime", 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<HighUserLoginLog> selectByExample(HighUserLoginLogExample example); |
||||||
|
|
||||||
|
@Select({ |
||||||
|
"select", |
||||||
|
"id, user_id, user_phone, platform, ip, province_name, city_code, city_name, ", |
||||||
|
"`status`, create_time, ext_1, ext_2, ext_3", |
||||||
|
"from high_user_login_log", |
||||||
|
"where id = #{id,jdbcType=BIGINT}" |
||||||
|
}) |
||||||
|
@Results({ |
||||||
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||||
|
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), |
||||||
|
@Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="create_time", property="createTime", 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) |
||||||
|
}) |
||||||
|
HighUserLoginLog selectByPrimaryKey(Long id); |
||||||
|
|
||||||
|
@UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByExampleSelective") |
||||||
|
int updateByExampleSelective(@Param("record") HighUserLoginLog record, @Param("example") HighUserLoginLogExample example); |
||||||
|
|
||||||
|
@UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByExample") |
||||||
|
int updateByExample(@Param("record") HighUserLoginLog record, @Param("example") HighUserLoginLogExample example); |
||||||
|
|
||||||
|
@UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByPrimaryKeySelective") |
||||||
|
int updateByPrimaryKeySelective(HighUserLoginLog record); |
||||||
|
|
||||||
|
@Update({ |
||||||
|
"update high_user_login_log", |
||||||
|
"set user_id = #{userId,jdbcType=BIGINT},", |
||||||
|
"user_phone = #{userPhone,jdbcType=VARCHAR},", |
||||||
|
"platform = #{platform,jdbcType=VARCHAR},", |
||||||
|
"ip = #{ip,jdbcType=VARCHAR},", |
||||||
|
"province_name = #{provinceName,jdbcType=VARCHAR},", |
||||||
|
"city_code = #{cityCode,jdbcType=VARCHAR},", |
||||||
|
"city_name = #{cityName,jdbcType=VARCHAR},", |
||||||
|
"`status` = #{status,jdbcType=INTEGER},", |
||||||
|
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||||
|
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||||
|
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||||
|
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||||
|
"where id = #{id,jdbcType=BIGINT}" |
||||||
|
}) |
||||||
|
int updateByPrimaryKey(HighUserLoginLog record); |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
package com.hai.dao; |
||||||
|
|
||||||
|
/** |
||||||
|
* mapper扩展类 |
||||||
|
*/ |
||||||
|
public interface HighUserLoginLogMapperExt { |
||||||
|
} |
@ -0,0 +1,346 @@ |
|||||||
|
package com.hai.dao; |
||||||
|
|
||||||
|
import com.hai.entity.HighUserLoginLog; |
||||||
|
import com.hai.entity.HighUserLoginLogExample.Criteria; |
||||||
|
import com.hai.entity.HighUserLoginLogExample.Criterion; |
||||||
|
import com.hai.entity.HighUserLoginLogExample; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import org.apache.ibatis.jdbc.SQL; |
||||||
|
|
||||||
|
public class HighUserLoginLogSqlProvider { |
||||||
|
|
||||||
|
public String countByExample(HighUserLoginLogExample example) { |
||||||
|
SQL sql = new SQL(); |
||||||
|
sql.SELECT("count(*)").FROM("high_user_login_log"); |
||||||
|
applyWhere(sql, example, false); |
||||||
|
return sql.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public String deleteByExample(HighUserLoginLogExample example) { |
||||||
|
SQL sql = new SQL(); |
||||||
|
sql.DELETE_FROM("high_user_login_log"); |
||||||
|
applyWhere(sql, example, false); |
||||||
|
return sql.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public String insertSelective(HighUserLoginLog record) { |
||||||
|
SQL sql = new SQL(); |
||||||
|
sql.INSERT_INTO("high_user_login_log"); |
||||||
|
|
||||||
|
if (record.getUserId() != null) { |
||||||
|
sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getUserPhone() != null) { |
||||||
|
sql.VALUES("user_phone", "#{userPhone,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getPlatform() != null) { |
||||||
|
sql.VALUES("platform", "#{platform,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getIp() != null) { |
||||||
|
sql.VALUES("ip", "#{ip,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getProvinceName() != null) { |
||||||
|
sql.VALUES("province_name", "#{provinceName,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityCode() != null) { |
||||||
|
sql.VALUES("city_code", "#{cityCode,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityName() != null) { |
||||||
|
sql.VALUES("city_name", "#{cityName,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.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(HighUserLoginLogExample example) { |
||||||
|
SQL sql = new SQL(); |
||||||
|
if (example != null && example.isDistinct()) { |
||||||
|
sql.SELECT_DISTINCT("id"); |
||||||
|
} else { |
||||||
|
sql.SELECT("id"); |
||||||
|
} |
||||||
|
sql.SELECT("user_id"); |
||||||
|
sql.SELECT("user_phone"); |
||||||
|
sql.SELECT("platform"); |
||||||
|
sql.SELECT("ip"); |
||||||
|
sql.SELECT("province_name"); |
||||||
|
sql.SELECT("city_code"); |
||||||
|
sql.SELECT("city_name"); |
||||||
|
sql.SELECT("`status`"); |
||||||
|
sql.SELECT("create_time"); |
||||||
|
sql.SELECT("ext_1"); |
||||||
|
sql.SELECT("ext_2"); |
||||||
|
sql.SELECT("ext_3"); |
||||||
|
sql.FROM("high_user_login_log"); |
||||||
|
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) { |
||||||
|
HighUserLoginLog record = (HighUserLoginLog) parameter.get("record"); |
||||||
|
HighUserLoginLogExample example = (HighUserLoginLogExample) parameter.get("example"); |
||||||
|
|
||||||
|
SQL sql = new SQL(); |
||||||
|
sql.UPDATE("high_user_login_log"); |
||||||
|
|
||||||
|
if (record.getId() != null) { |
||||||
|
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getUserId() != null) { |
||||||
|
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getUserPhone() != null) { |
||||||
|
sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getPlatform() != null) { |
||||||
|
sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getIp() != null) { |
||||||
|
sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getProvinceName() != null) { |
||||||
|
sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityCode() != null) { |
||||||
|
sql.SET("city_code = #{record.cityCode,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityName() != null) { |
||||||
|
sql.SET("city_name = #{record.cityName,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.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("high_user_login_log"); |
||||||
|
|
||||||
|
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||||
|
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); |
||||||
|
sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("city_code = #{record.cityCode,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("city_name = #{record.cityName,jdbcType=VARCHAR}"); |
||||||
|
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||||
|
sql.SET("create_time = #{record.createTime,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}"); |
||||||
|
|
||||||
|
HighUserLoginLogExample example = (HighUserLoginLogExample) parameter.get("example"); |
||||||
|
applyWhere(sql, example, true); |
||||||
|
return sql.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public String updateByPrimaryKeySelective(HighUserLoginLog record) { |
||||||
|
SQL sql = new SQL(); |
||||||
|
sql.UPDATE("high_user_login_log"); |
||||||
|
|
||||||
|
if (record.getUserId() != null) { |
||||||
|
sql.SET("user_id = #{userId,jdbcType=BIGINT}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getUserPhone() != null) { |
||||||
|
sql.SET("user_phone = #{userPhone,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getPlatform() != null) { |
||||||
|
sql.SET("platform = #{platform,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getIp() != null) { |
||||||
|
sql.SET("ip = #{ip,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getProvinceName() != null) { |
||||||
|
sql.SET("province_name = #{provinceName,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityCode() != null) { |
||||||
|
sql.SET("city_code = #{cityCode,jdbcType=VARCHAR}"); |
||||||
|
} |
||||||
|
|
||||||
|
if (record.getCityName() != null) { |
||||||
|
sql.SET("city_name = #{cityName,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.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, HighUserLoginLogExample 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,257 @@ |
|||||||
|
package com.hai.entity; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* high_user_login_log |
||||||
|
* @author |
||||||
|
*/ |
||||||
|
/** |
||||||
|
* |
||||||
|
* 代码由工具生成 |
||||||
|
* |
||||||
|
**/ |
||||||
|
public class HighUserLoginLog implements Serializable { |
||||||
|
/** |
||||||
|
* 主键 |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户id |
||||||
|
*/ |
||||||
|
private Long userId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户电话 |
||||||
|
*/ |
||||||
|
private String userPhone; |
||||||
|
|
||||||
|
/** |
||||||
|
* 登录平台 |
||||||
|
*/ |
||||||
|
private String platform; |
||||||
|
|
||||||
|
/** |
||||||
|
* ip地址 |
||||||
|
*/ |
||||||
|
private String ip; |
||||||
|
|
||||||
|
/** |
||||||
|
* 省份名称 |
||||||
|
*/ |
||||||
|
private String provinceName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 城市编码 |
||||||
|
*/ |
||||||
|
private String cityCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 城市名称 |
||||||
|
*/ |
||||||
|
private String cityName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 状态 0:删除 1:正常 |
||||||
|
*/ |
||||||
|
private Integer status; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* ext_1 |
||||||
|
*/ |
||||||
|
private String ext1; |
||||||
|
|
||||||
|
/** |
||||||
|
* ext_2 |
||||||
|
*/ |
||||||
|
private String ext2; |
||||||
|
|
||||||
|
/** |
||||||
|
* ext_3 |
||||||
|
*/ |
||||||
|
private String ext3; |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
public Long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(Long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public Long getUserId() { |
||||||
|
return userId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUserId(Long userId) { |
||||||
|
this.userId = userId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUserPhone() { |
||||||
|
return userPhone; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUserPhone(String userPhone) { |
||||||
|
this.userPhone = userPhone; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPlatform() { |
||||||
|
return platform; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPlatform(String platform) { |
||||||
|
this.platform = platform; |
||||||
|
} |
||||||
|
|
||||||
|
public String getIp() { |
||||||
|
return ip; |
||||||
|
} |
||||||
|
|
||||||
|
public void setIp(String ip) { |
||||||
|
this.ip = ip; |
||||||
|
} |
||||||
|
|
||||||
|
public String getProvinceName() { |
||||||
|
return provinceName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProvinceName(String provinceName) { |
||||||
|
this.provinceName = provinceName; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCityCode() { |
||||||
|
return cityCode; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCityCode(String cityCode) { |
||||||
|
this.cityCode = cityCode; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCityName() { |
||||||
|
return cityName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCityName(String cityName) { |
||||||
|
this.cityName = cityName; |
||||||
|
} |
||||||
|
|
||||||
|
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 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; |
||||||
|
} |
||||||
|
HighUserLoginLog other = (HighUserLoginLog) 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())) |
||||||
|
&& (this.getPlatform() == null ? other.getPlatform() == null : this.getPlatform().equals(other.getPlatform())) |
||||||
|
&& (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp())) |
||||||
|
&& (this.getProvinceName() == null ? other.getProvinceName() == null : this.getProvinceName().equals(other.getProvinceName())) |
||||||
|
&& (this.getCityCode() == null ? other.getCityCode() == null : this.getCityCode().equals(other.getCityCode())) |
||||||
|
&& (this.getCityName() == null ? other.getCityName() == null : this.getCityName().equals(other.getCityName())) |
||||||
|
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||||
|
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||||
|
&& (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 + ((getUserId() == null) ? 0 : getUserId().hashCode()); |
||||||
|
result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode()); |
||||||
|
result = prime * result + ((getPlatform() == null) ? 0 : getPlatform().hashCode()); |
||||||
|
result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode()); |
||||||
|
result = prime * result + ((getProvinceName() == null) ? 0 : getProvinceName().hashCode()); |
||||||
|
result = prime * result + ((getCityCode() == null) ? 0 : getCityCode().hashCode()); |
||||||
|
result = prime * result + ((getCityName() == null) ? 0 : getCityName().hashCode()); |
||||||
|
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||||
|
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().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(", userId=").append(userId); |
||||||
|
sb.append(", userPhone=").append(userPhone); |
||||||
|
sb.append(", platform=").append(platform); |
||||||
|
sb.append(", ip=").append(ip); |
||||||
|
sb.append(", provinceName=").append(provinceName); |
||||||
|
sb.append(", cityCode=").append(cityCode); |
||||||
|
sb.append(", cityName=").append(cityName); |
||||||
|
sb.append(", status=").append(status); |
||||||
|
sb.append(", createTime=").append(createTime); |
||||||
|
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,53 @@ |
|||||||
|
package com.hai.enum_type; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* 登录平台 |
||||||
|
* @className: LoginType |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/10/20 |
||||||
|
**/ |
||||||
|
public enum LoginPlatform { |
||||||
|
H5("WEB", "H5客户端"), |
||||||
|
WXAPPLETS("WXAPPLETS", "微信小程序"), |
||||||
|
UNIONPAY("UNIONPAY", "云闪付"), |
||||||
|
; |
||||||
|
|
||||||
|
private String code; |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
LoginPlatform(String code, String name) { |
||||||
|
this.code = code; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据类型查询数据 |
||||||
|
* @param code |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static LoginPlatform getDataByType(String code) { |
||||||
|
for (LoginPlatform ele : values()) { |
||||||
|
if(Objects.equals(code,ele.getCode())) return ele; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(String code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
package com.hai.enum_type; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* redis文件夹 |
||||||
|
* @className: RedisFileFolder |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/10/20 |
||||||
|
**/ |
||||||
|
public enum RedisFileFolder { |
||||||
|
SMS_CODE("SMS_CODE:", "短信验证码"), |
||||||
|
USER("USER:", "用户信息"), |
||||||
|
ADMIN("ADMIN:", "管理信息"), |
||||||
|
; |
||||||
|
|
||||||
|
private String code; |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
RedisFileFolder(String code, String name) { |
||||||
|
this.code = code; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据类型查询数据 |
||||||
|
* @param code |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static RedisFileFolder getDataByType(String code) { |
||||||
|
for (RedisFileFolder ele : values()) { |
||||||
|
if(Objects.equals(code,ele.getCode())) return ele; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(String code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<groupId>com.hai</groupId> |
||||||
|
<artifactId>hai-parent</artifactId> |
||||||
|
<version>1.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<groupId>com.hsg</groupId> |
||||||
|
<artifactId>hai-user</artifactId> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>com.hai</groupId> |
||||||
|
<artifactId>hai-service</artifactId> |
||||||
|
<version>PACKT-SNAPSHOT</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba.csp</groupId> |
||||||
|
<artifactId>sentinel-core</artifactId> |
||||||
|
<version>1.8.2</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba.csp</groupId> |
||||||
|
<artifactId>sentinel-transport-simple-http</artifactId> |
||||||
|
<version>1.8.2</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba.csp</groupId> |
||||||
|
<artifactId>sentinel-web-servlet</artifactId> |
||||||
|
<version>1.8.2</version> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<resources> |
||||||
|
<resource> |
||||||
|
<directory>src/main/resources/${env}</directory> |
||||||
|
<filtering>false</filtering> |
||||||
|
</resource> |
||||||
|
</resources> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-surefire-plugin</artifactId> |
||||||
|
<configuration> |
||||||
|
<skip>true</skip> |
||||||
|
</configuration> |
||||||
|
</plugin> |
||||||
|
<plugin> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
</build> |
||||||
|
|
||||||
|
|
||||||
|
</project> |
@ -0,0 +1,30 @@ |
|||||||
|
package com; |
||||||
|
|
||||||
|
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation; |
||||||
|
import com.alicp.jetcache.anno.config.EnableMethodCache; |
||||||
|
import com.hai.common.utils.SpringContextUtil; |
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.SpringApplication; |
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||||
|
import org.springframework.boot.web.servlet.ServletComponentScan; |
||||||
|
import org.springframework.context.ApplicationContext; |
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement; |
||||||
|
|
||||||
|
@SpringBootApplication |
||||||
|
//@ComponentScan
|
||||||
|
@EnableTransactionManagement |
||||||
|
@EnableScheduling |
||||||
|
@EnableMethodCache(basePackages = "com.hai") |
||||||
|
@EnableCreateCacheAnnotation |
||||||
|
@ServletComponentScan |
||||||
|
@MapperScan("com.hai.dao") |
||||||
|
public class UserApplication |
||||||
|
{ |
||||||
|
public static void main( String[] args ) |
||||||
|
{ |
||||||
|
ApplicationContext app = SpringApplication.run(UserApplication.class, args); |
||||||
|
SpringContextUtil.setApplicationContext(app); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule; |
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.RequestUtils; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.http.converter.HttpMessageConverter; |
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
||||||
|
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; |
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||||
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class AuthConfig implements WebMvcConfigurer { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(AuthConfig.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private UserCenter userCenter; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取配置文件debug变量 |
||||||
|
*/ |
||||||
|
@Value("${debug}") |
||||||
|
private boolean debug = false; |
||||||
|
|
||||||
|
/** |
||||||
|
* 解决18位long类型数据转json失去精度问题 |
||||||
|
* @param converters |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters){ |
||||||
|
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); |
||||||
|
|
||||||
|
ObjectMapper objectMapper = jsonConverter.getObjectMapper(); |
||||||
|
SimpleModule simpleModule = new SimpleModule(); |
||||||
|
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
||||||
|
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
||||||
|
objectMapper.registerModule(simpleModule); |
||||||
|
|
||||||
|
converters.add(jsonConverter); |
||||||
|
} |
||||||
|
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) { |
||||||
|
registry.addInterceptor(new HandlerInterceptorAdapter() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, |
||||||
|
Object handler) throws Exception { |
||||||
|
if(debug){ |
||||||
|
return true; |
||||||
|
} |
||||||
|
String token = request.getHeader("Authorization"); |
||||||
|
if (StringUtils.isNotBlank(token)) { |
||||||
|
if(userCenter.isLogin(request) == true) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
log.error("the user is not logged in,remoteAddr:"+ RequestUtils.getIpAddress(request)+",requestUrl:"+request.getRequestURL()); |
||||||
|
response.setStatus(401); |
||||||
|
return false; |
||||||
|
} |
||||||
|
}) |
||||||
|
.addPathPatterns("/**") |
||||||
|
.excludePathPatterns("/swagger-resources/**") |
||||||
|
.excludePathPatterns("/**/api-docs") |
||||||
|
.excludePathPatterns("/**/springfox-swagger-ui/**") |
||||||
|
.excludePathPatterns("/**/swagger-ui.html") |
||||||
|
.excludePathPatterns("/login/*") |
||||||
|
.excludePathPatterns("/sms/*") |
||||||
|
; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.ServletContextEvent; |
||||||
|
import javax.servlet.ServletContextListener; |
||||||
|
import javax.servlet.annotation.WebListener; |
||||||
|
|
||||||
|
@WebListener |
||||||
|
public class ConfigListener implements ServletContextListener { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private SysConfig sysConfig; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void contextInitialized(ServletContextEvent sce) { |
||||||
|
SysConst.setSysConfig(sysConfig); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void contextDestroyed(ServletContextEvent sce) { |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.web.cors.CorsConfiguration; |
||||||
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
||||||
|
import org.springframework.web.filter.CorsFilter; |
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @ClassName CorsConfig |
||||||
|
* @Description: TODO () |
||||||
|
* @Author 胡锐 |
||||||
|
* @Date 2020/12/16 |
||||||
|
**/ |
||||||
|
@Configuration |
||||||
|
public class CorsConfig extends WebMvcConfigurerAdapter { |
||||||
|
@Override |
||||||
|
public void addCorsMappings(CorsRegistry registry) { |
||||||
|
registry.addMapping("/**") |
||||||
|
.allowedOrigins("*") |
||||||
|
.allowCredentials(true) |
||||||
|
.allowedMethods("GET", "POST", "DELETE", "PUT") |
||||||
|
.maxAge(3600); |
||||||
|
} |
||||||
|
private CorsConfiguration buildConfig() { |
||||||
|
CorsConfiguration corsConfiguration = new CorsConfiguration(); |
||||||
|
List<String> list = new ArrayList<>(); |
||||||
|
list.add("*"); |
||||||
|
corsConfiguration.setAllowedOrigins(list); |
||||||
|
/* |
||||||
|
// 请求常用的三种配置,*代表允许所有,当时你也可以自定义属性(比如header只能带什么,只能是post方式等等)
|
||||||
|
*/ |
||||||
|
corsConfiguration.addAllowedOrigin("*"); |
||||||
|
corsConfiguration.addAllowedHeader("*"); |
||||||
|
corsConfiguration.addAllowedMethod("*"); |
||||||
|
return corsConfiguration; |
||||||
|
} |
||||||
|
@Bean |
||||||
|
public CorsFilter corsFilter() { |
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
||||||
|
source.registerCorsConfiguration("/**", buildConfig()); |
||||||
|
return new CorsFilter(source); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import org.springframework.boot.web.servlet.MultipartConfigFactory; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import javax.servlet.MultipartConfigElement; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class MultipartConfig { |
||||||
|
|
||||||
|
/** |
||||||
|
* 文件上传配置 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public MultipartConfigElement multipartConfigElement() { |
||||||
|
MultipartConfigFactory factory = new MultipartConfigFactory(); |
||||||
|
//文件最大
|
||||||
|
factory.setMaxFileSize("300MB"); //KB,MB
|
||||||
|
//设置总上传数据总大小
|
||||||
|
factory.setMaxRequestSize("350MB"); |
||||||
|
return factory.createMultipartConfig(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,110 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect; |
||||||
|
import com.fasterxml.jackson.annotation.PropertyAccessor; |
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
import org.springframework.cache.annotation.CachingConfigurerSupport; |
||||||
|
import org.springframework.cache.annotation.EnableCaching; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory; |
||||||
|
import org.springframework.data.redis.core.*; |
||||||
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer; |
||||||
|
|
||||||
|
|
||||||
|
@Configuration |
||||||
|
@EnableCaching //开启注解
|
||||||
|
public class RedisConfig extends CachingConfigurerSupport { |
||||||
|
|
||||||
|
/** |
||||||
|
* retemplate相关配置 |
||||||
|
* @param factory |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { |
||||||
|
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<>(); |
||||||
|
// 配置连接工厂
|
||||||
|
template.setConnectionFactory(factory); |
||||||
|
|
||||||
|
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
|
||||||
|
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); |
||||||
|
|
||||||
|
ObjectMapper om = new ObjectMapper(); |
||||||
|
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
|
||||||
|
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
||||||
|
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
|
||||||
|
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
||||||
|
jacksonSeial.setObjectMapper(om); |
||||||
|
|
||||||
|
// 值采用json序列化
|
||||||
|
template.setValueSerializer(jacksonSeial); |
||||||
|
//使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||||
|
template.setKeySerializer(new StringRedisSerializer()); |
||||||
|
|
||||||
|
// 设置hash key 和value序列化模式
|
||||||
|
template.setHashKeySerializer(new StringRedisSerializer()); |
||||||
|
template.setHashValueSerializer(jacksonSeial); |
||||||
|
template.afterPropertiesSet(); |
||||||
|
|
||||||
|
return template; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对hash类型的数据操作 |
||||||
|
* |
||||||
|
* @param redisTemplate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) { |
||||||
|
return redisTemplate.opsForHash(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对redis字符串类型数据操作 |
||||||
|
* |
||||||
|
* @param redisTemplate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) { |
||||||
|
return redisTemplate.opsForValue(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对链表类型的数据操作 |
||||||
|
* |
||||||
|
* @param redisTemplate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) { |
||||||
|
return redisTemplate.opsForList(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对无序集合类型的数据操作 |
||||||
|
* |
||||||
|
* @param redisTemplate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { |
||||||
|
return redisTemplate.opsForSet(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对有序集合类型的数据操作 |
||||||
|
* |
||||||
|
* @param redisTemplate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) { |
||||||
|
return redisTemplate.opsForZSet(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter; |
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import javax.servlet.Filter; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class SentinelFilterConfig { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public FilterRegistrationBean sentinelFilterRegistration() { |
||||||
|
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>(); |
||||||
|
registration.setFilter(new CommonFilter()); |
||||||
|
registration.addUrlPatterns("/*"); |
||||||
|
registration.setName("sentinelFilter"); |
||||||
|
registration.setOrder(1); |
||||||
|
|
||||||
|
return registration; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import springfox.documentation.builders.ApiInfoBuilder; |
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors; |
||||||
|
import springfox.documentation.service.ApiInfo; |
||||||
|
import springfox.documentation.service.Contact; |
||||||
|
import springfox.documentation.spi.DocumentationType; |
||||||
|
import springfox.documentation.spring.web.plugins.Docket; |
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
||||||
|
|
||||||
|
/** |
||||||
|
* SwaggerConfig.java |
||||||
|
* 项目名称: |
||||||
|
* 包: |
||||||
|
* 类名称: SwaggerConfig.java |
||||||
|
* 类描述: 构建restful api接口文档 |
||||||
|
* 创建人: |
||||||
|
* 创建时间: 2017 下午4:23:45 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
@EnableSwagger2 |
||||||
|
public class SwaggerConfig |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* 描述api的基本信息 |
||||||
|
* 基本信息会展现在文档页面中 |
||||||
|
* @return [api的基本信息] |
||||||
|
*/ |
||||||
|
ApiInfo apiInfo() |
||||||
|
{ |
||||||
|
return new ApiInfoBuilder().title("hsg-order").description("订单业务接口").termsOfServiceUrl("").version("1.0.0") |
||||||
|
.contact(new Contact("", "", "")).build(); |
||||||
|
} |
||||||
|
|
||||||
|
@Bean |
||||||
|
public Docket customImplementation() |
||||||
|
{ |
||||||
|
return new Docket(DocumentationType.SWAGGER_2).select() |
||||||
|
.apis(RequestHandlerSelectors.basePackage("com")) |
||||||
|
.build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) |
||||||
|
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||||
|
import org.springframework.context.annotation.PropertySource; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
@Component("sysConfig") |
||||||
|
@ConfigurationProperties |
||||||
|
@PropertySource("classpath:/config.properties") |
||||||
|
@Data |
||||||
|
public class SysConfig { |
||||||
|
|
||||||
|
private String fileUrl; |
||||||
|
|
||||||
|
// 微信小程序Appid
|
||||||
|
private String wxMiniAppId; |
||||||
|
// 微信小程序appSecret
|
||||||
|
private String wxMiniAppSecret; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
public class SysConst { |
||||||
|
|
||||||
|
private static SysConfig sysConfig; |
||||||
|
|
||||||
|
public static void setSysConfig(SysConfig arg){ |
||||||
|
sysConfig = arg; |
||||||
|
} |
||||||
|
|
||||||
|
public static SysConfig getSysConfig(){ |
||||||
|
if (null == sysConfig) { |
||||||
|
//防止空指针异常
|
||||||
|
sysConfig = new SysConfig(); |
||||||
|
return sysConfig; |
||||||
|
} |
||||||
|
return sysConfig; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package com.web.config; |
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.api.WxMaService; |
||||||
|
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
||||||
|
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import javax.annotation.PostConstruct; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class WxMaConfiguration { |
||||||
|
|
||||||
|
private static WxMaService maService; |
||||||
|
|
||||||
|
public static WxMaService getMaService() { |
||||||
|
if (maService == null) { |
||||||
|
throw new IllegalArgumentException(String.format("未找到对应的配置,请核实!")); |
||||||
|
} |
||||||
|
return maService; |
||||||
|
} |
||||||
|
|
||||||
|
@PostConstruct |
||||||
|
public void init() { |
||||||
|
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
||||||
|
config.setAppid(SysConst.getSysConfig().getWxMiniAppId()); |
||||||
|
config.setSecret(SysConst.getSysConfig().getWxMiniAppSecret()); |
||||||
|
maService = new WxMaServiceImpl(); |
||||||
|
maService.setWxMaConfig(config); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package com.web.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.MemberValidateUtil; |
||||||
|
import com.hai.common.utils.RedisUtil; |
||||||
|
import com.hai.common.utils.ResponseMsgUtil; |
||||||
|
import com.hai.enum_type.LoginPlatform; |
||||||
|
import com.hai.enum_type.RedisFileFolder; |
||||||
|
import com.hai.model.HighUserModel; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.model.UserInfoModel; |
||||||
|
import com.hai.service.HighUserService; |
||||||
|
import com.web.type.LoginType; |
||||||
|
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.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: CoresController |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/10/21 |
||||||
|
**/ |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/cores") |
||||||
|
@Api(value = "用户核心业务") |
||||||
|
public class CoresController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CoresController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisUtil redisUtil; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighUserService userService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private UserCenter userCenter; |
||||||
|
|
||||||
|
@RequestMapping(value = "/outLogin", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "退出登录") |
||||||
|
public ResponseData outLogin(HttpServletRequest request, HttpServletResponse response) { |
||||||
|
try { |
||||||
|
HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); |
||||||
|
if (userInfoModel == null) { |
||||||
|
log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); |
||||||
|
} |
||||||
|
userCenter.remove(request, response); |
||||||
|
return ResponseMsgUtil.success("退出登录成功"); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("CoresController --> outLogin() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
|||||||
|
package com.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.MemberValidateUtil;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.MessageConfig;
import com.hai.model.ResponseData;
import com.hai.service.HighUserService;
import com.hai.enum_type.RedisFileFolder;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Random;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/sms")
@Api(value = "短信服务")
public class SmsController {
private static Logger log = LoggerFactory.getLogger(SmsController.class);
@Resource
private RedisUtil redisUtil;
@Resource
private HighUserService userService;
@RequestMapping(value = "/getLoginSMSCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取登录验证码")
public ResponseData getLoginSMSCode(@RequestBody JSONObject body) {
try {
if (body == null || StringUtils.isBlank(body.getString("phone"))) {
log.error("LoginController --> phone() error!", "请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
String phone = body.getString("phone");
// 校验手机号格式
if (MemberValidateUtil.validatePhone(phone) == false) {
log.error("LoginController --> phone() error!", "请输入正确的手机号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
// 生成随机6位验证码
String smsCode = String.valueOf(new Random().nextInt(899999) + 100000);
MessageConfig.req(phone,smsCode, MessageConfig.HWMSG_ID5);
redisUtil.set(RedisFileFolder.SMS_CODE.getCode()+phone, smsCode, 60*5);
return ResponseMsgUtil.success("短信发送成功");
} catch (Exception e) {
log.error("SMSController --> getLoginSMSCode() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}
|
@ -0,0 +1 @@ |
|||||||
|
package com.web.controller;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighOrder;
import com.hai.model.ResponseData;
import com.hai.order.model.CreateOrderModel;
import com.hai.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/test")
@Api(value = "订单接口")
public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class);
@Autowired
private RocketMQTemplate rocketMQTemplate;
@Resource
private OrderService orderService;
@Resource
private RedisUtil redisUtil;
@Autowired
private RedisTemplate redisTemplate;
@RequestMapping(value = "/q", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "")
public ResponseData q(@RequestParam(name = "orderNo", required = true) String orderNo) {
try {
HighOrder order = orderService.getOrderDetailByNo(orderNo);
if (order != null) {
orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"));
// order.setRefundTime(new Date());
// orderService.updateOrderData(order);
return ResponseMsgUtil.success("修改成功");
}
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighUserCardController --> rocketMq() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/rocketMq", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "")
public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup,
@RequestParam(name = "body", required = true) String body) {
try {
long startTime = System.currentTimeMillis();
// org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build();
CreateOrderModel createOrder = new CreateOrderModel();
//发送对象消息
HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class);
System.out.println("订单号:" + order.getOrderNo());
// SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000);
/*List<HighOrder> list = new LinkedList<>();
for (int i = 0; i <= 100;i++) {
list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));
*//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//*
*//* updateUserWithRedisLock("coupon_" + couponKey, i+"");
new Thread(() -> {*//*
*//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i);
System.out.println("加入数据" + i);*//*
// redisTemplate.delete("coupon" + couponKey);
// System.out.println("释放数据" + index);
*//*
});*//*
}*/
System.out.println(System.currentTimeMillis() - startTime);
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighUserCardController --> rocketMq() error!", e);
return ResponseMsgUtil.exception(e);
}
}
public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException {
// 占分布式锁,去redis占坑
// 1. 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value);
if(lock) {
//加锁成功...
// todo business
System.out.println("加锁成功: " + value);
redisTemplate.delete("coupon" + couponKey); //删除key,释放锁
} else {
System.out.println("加锁失败");
/* Thread.sleep(100); // 加锁失败,重试
updateUserWithRedisLock("sysUser");*/
}
}
}
|
@ -0,0 +1,51 @@ |
|||||||
|
package com.web.type; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* 登录方式 |
||||||
|
* @className: LoginType |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/10/20 |
||||||
|
**/ |
||||||
|
public enum LoginType { |
||||||
|
SMS("SMS", "短信登录"), |
||||||
|
; |
||||||
|
|
||||||
|
private String code; |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
LoginType(String code, String name) { |
||||||
|
this.code = code; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据类型查询数据 |
||||||
|
* @param code |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static LoginType getDataByType(String code) { |
||||||
|
for (LoginType ele : values()) { |
||||||
|
if(Objects.equals(code,ele.getCode())) return ele; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(String code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,102 @@ |
|||||||
|
server: |
||||||
|
port: 9305 |
||||||
|
servlet: |
||||||
|
context-path: /user |
||||||
|
|
||||||
|
#配置是否为debug模式,debug模式下,不开启权限校验 |
||||||
|
debug: false |
||||||
|
|
||||||
|
#datasource数据源设置 |
||||||
|
spring: |
||||||
|
datasource: |
||||||
|
url: jdbc:mysql://139.159.177.244:3306/hsg_order?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false |
||||||
|
username: root |
||||||
|
password: HF123456. |
||||||
|
type: com.alibaba.druid.pool.DruidDataSource |
||||||
|
driver-class-name: com.mysql.jdbc.Driver |
||||||
|
filters: stat |
||||||
|
maxActive: 10 |
||||||
|
initialSize: 5 |
||||||
|
maxWait: 60000 |
||||||
|
minIdle: 5 |
||||||
|
timeBetweenEvictionRunsMillis: 60000 |
||||||
|
minEvictableIdleTimeMillis: 300000 |
||||||
|
validationQuery: select 'x' |
||||||
|
testWhileIdle: true |
||||||
|
testOnBorrow: false |
||||||
|
testOnReturn: false |
||||||
|
poolPreparedStatements: true |
||||||
|
maxOpenPreparedStatements: 20 |
||||||
|
redis: |
||||||
|
database: 0 |
||||||
|
host: 139.159.177.244 |
||||||
|
port: 36379 |
||||||
|
password: HF123456.Redis |
||||||
|
timeout: 1000 |
||||||
|
jedis: |
||||||
|
pool: |
||||||
|
max-active: 20 |
||||||
|
max-wait: -1 |
||||||
|
max-idle: 10 |
||||||
|
min-idle: 0 |
||||||
|
#MQTT配置信息 |
||||||
|
mqtt: |
||||||
|
#MQTT服务地址 |
||||||
|
url: ws://139.159.177.244:8083/mqtt |
||||||
|
#用户名 |
||||||
|
username: printer_provider |
||||||
|
#密码 |
||||||
|
password: 123654 |
||||||
|
#客户端id(不能重复) |
||||||
|
# client: |
||||||
|
# id: provider-id |
||||||
|
#MQTT默认的消息推送主题,实际可在调用接口是指定 |
||||||
|
# default: |
||||||
|
# topic: topic |
||||||
|
rocketmq: |
||||||
|
name-server: 139.159.177.244:9876 |
||||||
|
producer: |
||||||
|
#必须指定group |
||||||
|
group: default-group |
||||||
|
|
||||||
|
#配置日期返回至前台为时间戳 |
||||||
|
jackson: |
||||||
|
serialization: |
||||||
|
write-dates-as-timestamps: true |
||||||
|
mybatis: |
||||||
|
mapperLocations: |
||||||
|
- classpath*:sqlmap*/*.xml |
||||||
|
type-aliases-package: |
||||||
|
org.springboot.sample.entity |
||||||
|
configuration: |
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||||
|
#开启MyBatis的二级缓存 |
||||||
|
cache-enabled: true |
||||||
|
|
||||||
|
jetcache: |
||||||
|
statIntervalMinutes: 15 |
||||||
|
areaInCacheName: false |
||||||
|
local: |
||||||
|
default: |
||||||
|
type: linkedhashmap |
||||||
|
keyConvertor: fastjson |
||||||
|
remote: |
||||||
|
default: |
||||||
|
type: redis |
||||||
|
host: 139.159.177.244 |
||||||
|
port: 36379 |
||||||
|
password: HF123456.Redis |
||||||
|
keyConvertor: fastjson |
||||||
|
broadcastChannel: projectA |
||||||
|
valueEncoder: java |
||||||
|
valueDecoder: java |
||||||
|
poolConfig: |
||||||
|
minIdle: 5 |
||||||
|
maxIdle: 20 |
||||||
|
maxTotal: 50 |
||||||
|
|
||||||
|
pagehelper: |
||||||
|
helperDialect: mysql |
||||||
|
reasonable: true |
||||||
|
supportMethodsArguments: true |
||||||
|
params: count=countSql |
@ -0,0 +1,27 @@ |
|||||||
|
# \u03A2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD |
||||||
|
wxAppId=wx8d49e2f83025229d |
||||||
|
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df |
||||||
|
|
||||||
|
wxH5AppId=wxa075e8509802f826 |
||||||
|
wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 |
||||||
|
|
||||||
|
wxApiKey=Skufk5oi85wDFGl888i6wsRSTkdd5df5 |
||||||
|
wxMchAppId=wx637bd6f7314daa46 |
||||||
|
wxMchId=1289663601 |
||||||
|
wxSubAppId=wx8d49e2f83025229d |
||||||
|
wxSubMchId=1609882817 |
||||||
|
wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder |
||||||
|
wxGzSubAppId=wxa075e8509802f826 |
||||||
|
wxGzSubMchId=1619676214 |
||||||
|
|
||||||
|
# ???????????? |
||||||
|
HDAppId = 1614670195 |
||||||
|
|
||||||
|
notifyUrl=https://hsgcs.dctpay.com/crest/wechatpay/notify |
||||||
|
imgUrl=https://hsgcs.dctpay.com/filesystem/ |
||||||
|
|
||||||
|
fileUrl=/home/project/hsg/filesystem |
||||||
|
cmsPath=/home/project/hsg/filesystem/cmsPath |
||||||
|
couponCodePath=/home/project/hsg/filesystem/couponCode |
||||||
|
|
||||||
|
qrCodeUrl=https://hsgcs.dctpay.com/hsgH5?accountId=0000010&key=&code= |
@ -0,0 +1,93 @@ |
|||||||
|
<configuration> |
||||||
|
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, --> |
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||||
|
<encoder> |
||||||
|
<pattern>%d %p (%file:%line\)- %m%n</pattern> |
||||||
|
<charset>UTF-8</charset> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
<appender name="baselog" |
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<File>log/base.log</File> |
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<fileNamePattern>log/base.log.%d.%i</fileNamePattern> |
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||||
|
<!-- or whenever the file size reaches 64 MB --> |
||||||
|
<maxFileSize>64 MB</maxFileSize> |
||||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||||
|
</rollingPolicy> |
||||||
|
<encoder> |
||||||
|
<pattern> |
||||||
|
%d %p (%file:%line\)- %m%n |
||||||
|
</pattern> |
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
<appender name="daolog" |
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<File>log/dao.log</File> |
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<fileNamePattern>log/dao.log.%d.%i</fileNamePattern> |
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||||
|
<!-- or whenever the file size reaches 64 MB --> |
||||||
|
<maxFileSize>64 MB</maxFileSize> |
||||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||||
|
</rollingPolicy> |
||||||
|
<encoder> |
||||||
|
<pattern> |
||||||
|
%d %p (%file:%line\)- %m%n |
||||||
|
</pattern> |
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
<appender name="errorlog" |
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<File>log/error.log</File> |
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<fileNamePattern>log/error.log.%d.%i</fileNamePattern> |
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||||
|
<!-- or whenever the file size reaches 64 MB --> |
||||||
|
<maxFileSize>64 MB</maxFileSize> |
||||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||||
|
</rollingPolicy> |
||||||
|
<encoder> |
||||||
|
<pattern> |
||||||
|
%d %p (%file:%line\)- %m%n |
||||||
|
</pattern> |
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
<root level="DEBUG"> |
||||||
|
<appender-ref ref="STDOUT" /> |
||||||
|
</root> |
||||||
|
<logger name="com.hai" level="INFO"> |
||||||
|
<appender-ref ref="baselog" /> |
||||||
|
</logger> |
||||||
|
<logger name="com.hai.dao" level="DEBUG"> |
||||||
|
<appender-ref ref="daolog" /> |
||||||
|
</logger> |
||||||
|
<logger name="com.hai" level="ERROR"> |
||||||
|
<appender-ref ref="errorlog" /> |
||||||
|
</logger> |
||||||
|
|
||||||
|
|
||||||
|
<appender name="ChongQingCNPC" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<File>log/ChongQingCNPCService.log</File> |
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<fileNamePattern>log/ChongQingCNPCService.log.%d.%i</fileNamePattern> |
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||||
|
<!-- or whenever the file size reaches 64 MB --> |
||||||
|
<maxFileSize>64 MB</maxFileSize> |
||||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||||
|
</rollingPolicy> |
||||||
|
<encoder> |
||||||
|
<pattern> |
||||||
|
%d %p (%file:%line\)- %m%n |
||||||
|
</pattern> |
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
<logger name="com.hai.config.ChongQingCNPCService" level="INFO"> |
||||||
|
<appender-ref ref="ChongQingCNPC" /> |
||||||
|
</logger> |
||||||
|
</configuration> |
Loading…
Reference in new issue