| | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Document(collation = "luckyImage") |
| | | @Document(collection = "luckyActivityImage") |
| | | public class LuckyActivityImage implements Serializable { |
| | | public enum LuckyImageType { |
| | | banner("banner"); |
| | |
| | | * @param eventKey |
| | | * @return |
| | | */ |
| | | public boolean isAssisted(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey); |
| | | public boolean isAssisted(@NotNull Long joinId, @NotNull Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param eventKey |
| | | * @return |
| | | */ |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey); |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotNull Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey); |
| | | |
| | | |
| | | /** |
| | |
| | | * @throws LuckyActivityException |
| | | * @throws LuckyActivityJoinException |
| | | */ |
| | | public void join(@NotNull Long activityId, @NotNull Long appId, @NotEmpty String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException; |
| | | public void join(@NotNull Long activityId, @NotNull Long appId, @NotEmpty String uid, Integer weight, JoinInfo joinInfo,int userType) throws LuckyActivityException, LuckyActivityJoinException; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取有效的活动列表 |
| | | * @param appId |
| | | * @param sponsorId |
| | | * @param stateList |
| | | * @param excludeActivityIds 排除某些活动ID |
| | | * @param key |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<LuckyActivity> getActivityList(Long appId, Long sponsorId, List<Integer> stateList, List<Long> excludeActivityIds, String key, int page, int pageSize); |
| | | |
| | | /** |
| | | * 有效的活动计数 |
| | | * |
| | | * @param appId |
| | |
| | | |
| | | |
| | | /** |
| | | * 有效的活动计数 |
| | | * @param appId |
| | | * @param sponsorId |
| | | * @param stateList |
| | | * @param key |
| | | * @param excludeActivityIds 排除某些活动ID |
| | | * @return |
| | | */ |
| | | public long countActivity(Long appId, Long sponsorId, List<Integer> stateList, String key, List<Long> excludeActivityIds); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 创建活动 |
| | | * |
| | | * @param activity |
| | |
| | | name: app-provider |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://192.168.3.253:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://192.168.3.136:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
New file |
| | |
| | | package com.ks.daylucky.aspect; |
| | | |
| | | import com.ks.daylucky.manager.RedisManager; |
| | | import com.ks.daylucky.util.annotation.RequestSerializable; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.springframework.core.DefaultParameterNameDiscoverer; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.expression.EvaluationContext; |
| | | import org.springframework.expression.Expression; |
| | | import org.springframework.expression.ExpressionParser; |
| | | import org.springframework.expression.spel.standard.SpelExpressionParser; |
| | | import org.springframework.expression.spel.support.StandardEvaluationContext; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.params.SetParams; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Method; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | @Aspect |
| | | @Order(4) |
| | | public class RequestSerializableAspect { |
| | | |
| | | private Set<Long> waitingThreadSet = new HashSet<>(); |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | private ExpressionParser parser = new SpelExpressionParser(); |
| | | |
| | | private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer(); |
| | | |
| | | /** |
| | | * 获取表达的值 |
| | | * |
| | | * @param spELString |
| | | * @param joinPoint |
| | | * @return |
| | | */ |
| | | public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) { |
| | | MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); |
| | | String[] paramNames = nameDiscoverer.getParameterNames(methodSignature.getMethod()); |
| | | Expression expression = parser.parseExpression(spELString); |
| | | EvaluationContext context = new StandardEvaluationContext(); |
| | | Object[] args = joinPoint.getArgs(); |
| | | for (int i = 0; i < args.length; i++) { |
| | | context.setVariable(paramNames[i], args[i]); |
| | | } |
| | | return expression.getValue(context).toString(); |
| | | } |
| | | |
| | | @Around("execution(public * com.ks.daylucky.controller.api.client..*.*(..))") |
| | | public Object requestSerializable(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method targetMethod = methodSignature.getMethod(); |
| | | String cacheKey = null; |
| | | |
| | | Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(joinPoint.getSignature().getName(), |
| | | targetMethod.getParameterTypes()); |
| | | |
| | | |
| | | if (realMethod.isAnnotationPresent(RequestSerializable.class)) { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | RequestSerializable rs = realMethod.getAnnotation(RequestSerializable.class); |
| | | String key = rs.key(); |
| | | cacheKey = generateKeyBySpEL(key, joinPoint); |
| | | |
| | | try {// redis做原子性保护 |
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) { |
| | | cacheKey = joinPoint.getTarget().getClass().getName() + "." + targetMethod.getName() + "-" |
| | | + cacheKey; |
| | | String cacheAlias = cacheKey; |
| | | cacheKey = "rs-" + StringUtil.Md5(cacheKey); |
| | | // jiedis原子性做拦截 |
| | | Jedis jedis = redisManager.getJedis(); |
| | | long threadId = Thread.currentThread().getId(); |
| | | try { |
| | | waitingThreadSet.add(threadId); |
| | | String result = null; |
| | | long startTime = System.currentTimeMillis(); |
| | | // 等待响应 |
| | | while (StringUtil.isNullOrEmpty(result)) { |
| | | result = jedis.set(cacheKey, "1", new SetParams().nx().ex(30)); |
| | | if (StringUtil.isNullOrEmpty(result)) { |
| | | try { |
| | | Thread.sleep(50); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (System.currentTimeMillis() - startTime > 1000 * 30L) { |
| | | waitingThreadSet.remove(Thread.currentThread().getId()); |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | out.print(JsonUtil.loadFalseResult("连接超时")); |
| | | return null; |
| | | } |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | try { |
| | | return joinPoint.proceed(); |
| | | } finally { |
| | | jedis.del(cacheKey); |
| | | waitingThreadSet.remove(Thread.currentThread().getId()); |
| | | } |
| | | } |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | } catch (Exception e) {// 原子性保护出错 |
| | | return joinPoint.proceed(); |
| | | } |
| | | } |
| | | |
| | | |
| | | return joinPoint.proceed(); |
| | | |
| | | } |
| | | |
| | | class ParamsTypeValue { |
| | | Class<?> type; |
| | | Object value; |
| | | |
| | | public ParamsTypeValue(Class<?> type, Object value) { |
| | | this.type = type; |
| | | this.value = value; |
| | | } |
| | | |
| | | public ParamsTypeValue() { |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.config; |
| | | |
| | | import org.apache.commons.pool2.impl.GenericObjectPoolConfig; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import redis.clients.jedis.JedisPool; |
| | | |
| | | @Configuration |
| | | public class RedisConfig { |
| | | Logger log = LoggerFactory.getLogger(RedisConfig.class); |
| | | |
| | | @Value("${redis.host}") |
| | | private String host; |
| | | |
| | | @Value("${redis.port}") |
| | | private int port; |
| | | |
| | | @Value("${redis.password}") |
| | | private String password; |
| | | |
| | | @Value("${redis.timeout}") |
| | | private int timeout; |
| | | |
| | | @Value("${redis.jedis.pool.max-wait}") |
| | | private int maxWait; |
| | | |
| | | @Value("${redis.jedis.pool.max-idle}") |
| | | private int maxIdle; |
| | | |
| | | @Value("${redis.jedis.pool.max-total}") |
| | | private int maxTotal; |
| | | @Value("${redis.database}") |
| | | private int database; |
| | | |
| | | |
| | | @Bean |
| | | public JedisPool jedisPool() { |
| | | GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); |
| | | poolConfig.setMaxWaitMillis(maxWait); |
| | | poolConfig.setMaxIdle(maxIdle); |
| | | poolConfig.setMaxTotal(maxTotal); |
| | | JedisPool pool = new JedisPool(poolConfig, host, port, timeout, password, database); |
| | | return pool; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | LuckyActivityJoinRecord record = luckyActivityJoinService.getJoinInfo(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | LuckyActivityJoinRecord record = luckyActivityJoinService.getJoinInfo(activityId, acceptData.getApp().getId(), dto.getUid() + ""); |
| | | //不存在助力 |
| | | if (record == null) { |
| | | return JsonUtil.loadFalseResult(""); |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity") |
| | | public class ActivityController { |
| | | |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityJoinAssistService luckyActivityJoinAssistService; |
| | | |
| | | @Resource |
| | |
| | | @ResponseBody |
| | | @RequestMapping("getActivityDetail") |
| | | public String getActivityDetail(AcceptData acceptData, Long activityId) { |
| | | ActivityDetailInfoDTO dto = activityService.getActivityDetail(activityId, acceptData.getApp().getId(), acceptData.getUid(), true, 20, false); |
| | | ActivityDetailInfoDTO dto = activityService.getActivityDetail(activityId, acceptData.getApp().getId(), acceptData.getUid(), true, 8, false); |
| | | if (dto == null) { |
| | | return JsonUtil.loadFalseResult("活动不存在"); |
| | | } |
| | |
| | | |
| | | //已经加入活动就需要返回助力分享图 |
| | | if (vo.isJoined()) { |
| | | |
| | | SimpleUser user = userInfoService.getSimpleUser(acceptData.getUid()); |
| | | if (user != null) { |
| | | String assistShareImage = null; |
| | |
| | | } |
| | | List<ActivityDetailInfoDTO> dtoList = activityService.getActivityDetail(activityIds, acceptData.getApp().getId(), acceptData.getUid(), false); |
| | | |
| | | //TODO 测试 |
| | | for (int i = 0; i < 20; i++) { |
| | | dtoList.add(dtoList.get(0)); |
| | | } |
| | | // //TODO 测试 |
| | | // for (int i = 0; i < 20; i++) { |
| | | // dtoList.add(dtoList.get(0)); |
| | | // } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", JsonUtil.getSimpleGson().toJson(ActivityListItemInfoVOFactory.create(dtoList))); |
| | |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getSponsorActivity") |
| | | public String getSponsorActivity(AcceptData acceptData, Long sponsorId, int page) { |
| | | public String getSponsorActivity(AcceptData acceptData, Long sponsorId, Long activityId, int page) { |
| | | |
| | | List<LuckyActivity> list = luckyActivityService.getActivityList(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null, page, Constant.CLIENT_ACTIVITY_LIST_PAGE_SIZE); |
| | | long count = luckyActivityService.countActivity(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null); |
| | | List<LuckyActivity> list = luckyActivityService.getActivityList(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), Arrays.asList(new Long[]{activityId}), |
| | | null, page, Constant.CLIENT_ACTIVITY_LIST_PAGE_SIZE); |
| | | long count = luckyActivityService.countActivity(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null, Arrays.asList(new Long[]{activityId})); |
| | | |
| | | List<Long> activityIds = new ArrayList<>(); |
| | | if (list != null && list.size() > 0) { |
| | |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.*; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardResultService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | |
| | | joinInfo.setAlipayUid(userInfo.getAlipayUid()); |
| | | try { |
| | | int weight = 1; |
| | | luckyActivityJoinService.join(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", 1, joinInfo); |
| | | luckyActivityJoinService.join(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", 1, joinInfo, LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | |
| | | //TODO 抽奖活动的类型需要替换 |
| | | return JsonUtil.loadTrueResult(new JoinResultInfoVO(weight, String.format("活动期号:NO.%s\n抽奖活动", activityId))); |
| | |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.daylucky.exception.UserInfoException; |
| | | import com.ks.daylucky.exception.UserInfoExtraException; |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DO.UserInfoExtra; |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.pojo.DTO.AlipayUserInfo; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.DTO.TokenDTO; |
| | | import com.ks.daylucky.pojo.DTO.UserMsgSettings; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.UserConfigVO; |
| | | import com.ks.daylucky.pojo.VO.UserMsgVO; |
| | | import com.ks.daylucky.service.AppConfigService; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.RSAUtil; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.annotation.RequestSerializable; |
| | | import com.ks.daylucky.util.factory.vo.UserMsgVOFactory; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | @Resource |
| | | private UserMsgService userMsgService; |
| | | |
| | | @Resource |
| | | private AppConfigService appConfigService; |
| | | |
| | | private AlipayAppInfo getAlipayAppInfo(AppInfo app) { |
| | | AppAlipayInfoWithBLOBs alipay = app.getAlipayInfo(); |
| | | AlipayAppInfo info = new AlipayAppInfo(alipay.getAlipayAppId(), alipay.getAlipayPrivateKey(), new AlipayCertInfo(new ByteArrayInputStream(alipay.getAlipayAppCertPublicKey()), new ByteArrayInputStream(alipay.getAlipayPublicCert()), new ByteArrayInputStream(alipay.getAlipayRootCert()))); |
| | | return info; |
| | | } |
| | | |
| | | @RequestSerializable(key = "'getToken-'+#alipayCode") |
| | | @ResponseBody |
| | | @RequestMapping("getToken") |
| | | public String getToken(AcceptData acceptData, String alipayCode, String wxCode) { |
| | |
| | | user.setNickName(alipayUserInfo.getNickName()); |
| | | user.setAlipayNickName(alipayUserInfo.getNickName()); |
| | | user.setAlipayPortrait(alipayUserInfo.getAvatar()); |
| | | if (user.getPortrait() != null && user.getPortrait().endsWith("undefined")) { |
| | | user.setPortrait(null); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(user.getNickName())) { |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), ConfigKeyEnum.defaultNickNamePrefix, acceptData.getVersion()); |
| | | user.setNickName(config.getValue() + acceptData.getUid()); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(user.getPortrait())) { |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), ConfigKeyEnum.defaultPortrait, acceptData.getVersion()); |
| | | user.setPortrait(config.getValue()); |
| | | } |
| | | |
| | | |
| | | userInfoService.updateUserInfo(user); |
| | | |
| | | user = userInfoService.getUserDetail(user.getId()); |
| | |
| | | package com.ks.daylucky.manager; |
| | | |
| | | import com.ks.lib.common.util.RedisUtil; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.SerializeUtil; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.params.SetParams; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | public class RedisManager { |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | private JedisPool jedisPool; |
| | | |
| | | private RedisUtil redisUtil = null; |
| | | public Jedis getJedis() { |
| | | Jedis jedis = jedisPool.getResource(); |
| | | return jedis; |
| | | } |
| | | |
| | | //注入Redis监听 |
| | | public void setRedisUtil() { |
| | | if (redisUtil == null) { |
| | | redisUtil = new RedisUtil(redisTemplate); |
| | | private void setString(String key, String value, int seconds) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.setex(key, seconds, value); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 缓存字符串 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | private void setString(String key, String value) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.set(key, value); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void remove(String... keys) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.del(keys); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | public void removePrefix(String... keys) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | for (String key : keys) { |
| | | Set<String> sets = jedis.keys(key + "*"); |
| | | if (sets != null) { |
| | | for (String k : sets) { |
| | | jedis.del(k); |
| | | } |
| | | } |
| | | } |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | private String getString(String key) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | return jedis.get(key); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void get() { |
| | | redisUtil.get(""); |
| | | public String getCommonString(String key) { |
| | | return getString(key); |
| | | } |
| | | |
| | | public void cacheCommonString(String key, String value, int seconds) { |
| | | setString(key, value, seconds); |
| | | } |
| | | |
| | | public void cacheCommonString(String key, String value) { |
| | | setString(key, value); |
| | | } |
| | | |
| | | /** |
| | | * 从redis缓存中查询,反序列化 |
| | | * |
| | | * @param redisKey |
| | | * @return |
| | | */ |
| | | public Object getDataFromRedis(String redisKey) { |
| | | //查询 |
| | | Jedis jedis = jedisPool.getResource(); |
| | | try { |
| | | byte[] result = jedis.get(redisKey.getBytes()); |
| | | |
| | | //如果查询没有为空 |
| | | if (null == result) { |
| | | return null; |
| | | } |
| | | |
| | | //查询到了,反序列化 |
| | | return SerializeUtil.unSerialize(result); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将数据库中查询到的数据放入redis |
| | | * |
| | | * @param redisKey |
| | | * @param obj |
| | | */ |
| | | public void setDataToRedis(String redisKey, Object obj, Integer seconds) { |
| | | |
| | | //序列化 |
| | | byte[] bytes = SerializeUtil.serialize(obj); |
| | | |
| | | SetParams params = null; |
| | | if (seconds != null) { |
| | | params = new SetParams().nx().ex(seconds); |
| | | } |
| | | //存入redis |
| | | Jedis jedis = jedisPool.getResource(); |
| | | try { |
| | | jedis.set(redisKey.getBytes(), bytes, params); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import org.springframework.data.annotation.Transient; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | public class UserInfo { |
| | | //正常用户 |
| | | public final static int TYPE_NORMAL = 1; |
| | | //虚拟用户 |
| | | public final static int TYPE_VIRTUAL = 2; |
| | | //尚未登录 |
| | | public final static int STATE_NO_LOGIN = 0; |
| | | //已经登录 |
| | | public final static int STATE_LOGINED = 1; |
| | | |
| | | |
| | | @Expose |
| | | private Long id; |
| | | @Expose |
| | |
| | | |
| | | private Date updateTime; |
| | | |
| | | private Integer type; |
| | | |
| | | private Integer state; |
| | | |
| | | private String stateDesc; |
| | | |
| | | @Transient |
| | | private UserInfoExtra userInfoExtra; |
| | | |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public Integer getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(Integer state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public String getStateDesc() { |
| | | return stateDesc; |
| | | } |
| | | |
| | | public void setStateDesc(String stateDesc) { |
| | | this.stateDesc = stateDesc; |
| | | } |
| | | |
| | | public String getAlipayNickName() { |
| | | return alipayNickName; |
| | | } |
| | |
| | | disclaimers("disclaimers", "免责声明"), |
| | | shareImageLink("share_image_link", "应用分享图"), |
| | | activityShareImageBg("activity_share_image_bg", "活动分享底图"), |
| | | assistShareImageBg("assist_share_image_bg", "助力分享底图"); |
| | | assistShareImageBg("assist_share_image_bg", "助力分享底图"), |
| | | defaultPortrait("default_portrait", "默认头像"), |
| | | defaultNickNamePrefix("default_nick_name_prefix", "默认昵称"); |
| | | |
| | | private String key; |
| | | |
| | |
| | | |
| | | @Service |
| | | public class ActivityServiceImpl implements ActivityService { |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityJoinService luckyActivityJoinService; |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityAwardService luckyActivityAwardService; |
| | | |
| | | @Resource |
| | |
| | | if (maxJoinerCount != null) { |
| | | //获取最近的参与者列表 |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, null,1, Constant.PAGE_SIZE); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getRecentJoinerList(activityId, maxJoinerCount); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
New file |
| | |
| | | package com.ks.daylucky.util.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | @Documented |
| | | @Target(ElementType.METHOD) |
| | | @Inherited |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface RequestSerializable { |
| | | String key(); |
| | | } |
| | |
| | | port: 27016 |
| | | database: day-lucky |
| | | authentication-database: admin |
| | | redis: |
| | | host: 192.168.3.253 |
| | | port: 6379 |
| | | password: '123456' |
| | | timeout: 5000 |
| | | jedis: |
| | | pool: |
| | | max-wait: 10000 |
| | | max-idle: 200 |
| | | max-active: 1024 |
| | | database: 3 |
| | | |
| | | datasource: |
| | | url: jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ks_day_lucky |
| | | url: jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ks_day_lucky?&useTimezone=true&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: Yeshi2016@ |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | |
| | | type-aliases-package: com.ks.goldcorn.pojo.DO |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl |
| | | redis: |
| | | host: 193.112.34.40 |
| | | port: 6379 |
| | | password: 'weikou2014' |
| | | timeout: 5000 |
| | | jedis: |
| | | pool: |
| | | max-wait: 10000 |
| | | max-idle: 200 |
| | | max-total: 1024 |
| | | database: 5 |
| | | |
| | | dubbo: |
| | | application: |
| | | name: daylucky-provider |
| | | name: daylucky-consumer |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://192.168.3.253:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://192.168.3.136:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.ks.daylucky.mapper.UserInfoMapper"> |
| | | <resultMap id="BaseResultMap" type="com.ks.daylucky.pojo.DO.UserInfo"> |
| | | <id column="id" property="id" jdbcType="BIGINT"/> |
| | |
| | | <result column="mobile" property="mobile" jdbcType="VARCHAR"/> |
| | | <result column="alipay_uid" property="alipayUid" jdbcType="VARCHAR"/> |
| | | <result column="alipay_portrait" property="alipayPortrait" jdbcType="VARCHAR"/> |
| | | <result column="alipay_nick_name" property="alipayNickName" jdbcType="VARCHAR"/> |
| | | <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR"/> |
| | | <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR"/> |
| | | <result column="wx_portrait" property="wxPortrait" jdbcType="VARCHAR"/> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="type" property="type" jdbcType="INTEGER"/> |
| | | <result column="state" property="state" jdbcType="INTEGER"/> |
| | | <result column="state_desc" property="stateDesc" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, app_id, identify_code, nick_name, portrait, mobile, alipay_uid, alipay_portrait, |
| | | wx_open_id, wx_union_id, wx_portrait, create_time, update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | select |
| | | <sql id="Base_Column_List">id, app_id, identify_code, nick_name, portrait, mobile, alipay_uid, alipay_portrait, wx_open_id, wx_union_id, wx_portrait, create_time, update_time,alipay_nick_name,`type`,state,state_desc</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/> |
| | | from user_info |
| | | where id = #{id,jdbcType=BIGINT} |
| | | from user_info where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <!-- 非模板 --> |
| | | |
| | | <sql id="listWhere"> |
| | | <if test="query.appId!=null"> |
| | | and app_id=#{query.appId} |
| | | </if> |
| | | |
| | | <if test="query.identifyCode!=null"> |
| | | and identify_code=#{query.identifyCode} |
| | | </if> |
| | | |
| | | <if test="query.key!=null"> |
| | | and nick_name like '${query.key}%' |
| | | </if> |
| | | |
| | | <if test="query.mobile!=null"> |
| | | and mobile=#{query.mobile} |
| | | </if> |
| | | |
| | | <if test="query.alipayUid!=null"> |
| | | and alipay_uid=#{query.alipayUid} |
| | | </if> |
| | | |
| | | <if test="query.wxOpenId!=null"> |
| | | and wx_open_id=#{query.wxOpenId} |
| | | </if> |
| | | |
| | | <if test="query.wxUnionId!=null"> |
| | | and wx_union_id=#{query.wxUnionId} |
| | | </if> |
| | | |
| | | |
| | | <if test="query.minCreateTime!=null"> |
| | | and create_time>=#{query.minCreateTime} |
| | | </if> |
| | | |
| | | <if test="query.maxCreateTime!=null"> |
| | | and #{query.maxCreateTime}>create_time |
| | | </if> |
| | | |
| | | <if test="query.appId!=null">and app_id=#{query.appId}</if> |
| | | <if test="query.identifyCode!=null">and identify_code=#{query.identifyCode}</if> |
| | | <if test="query.key!=null">and nick_name like '${query.key}%'</if> |
| | | <if test="query.mobile!=null">and mobile=#{query.mobile}</if> |
| | | <if test="query.alipayUid!=null">and alipay_uid=#{query.alipayUid}</if> |
| | | <if test="query.wxOpenId!=null">and wx_open_id=#{query.wxOpenId}</if> |
| | | <if test="query.wxUnionId!=null">and wx_union_id=#{query.wxUnionId}</if> |
| | | <if test="query.minCreateTime!=null">and create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>create_time</if> |
| | | </sql> |
| | | |
| | | |
| | | <select id="list" resultMap="BaseResultMap"> |
| | | select |
| | | <select id="list" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from user_info |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | |
| | | |
| | | from user_info where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | </foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">${item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | |
| | | |
| | | <select id="listUserInfo" resultMap="BaseResultMap"> |
| | | select |
| | | <select id="listUserInfo" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from user_info |
| | | where 1=1 |
| | | <foreach collection="userList" item="user" open=" and (" close=")" separator=" or "> |
| | | #{user.uid}=id and app_id=#{user.appId} |
| | | from user_info where 1=1 |
| | | <foreach collection="userList" item="user" open=" and (" close=")" separator=" or ">#{user.uid}=id and |
| | | app_id=#{user.appId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from user_info |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | <select id="count" resultType="java.lang.Long">select count(*) from user_info where 1=1 |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | delete from user_info |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.daylucky.pojo.DO.UserInfo"> |
| | | insert into user_info (id, app_id, identify_code, |
| | | nick_name, portrait, mobile, |
| | | alipay_uid, alipay_portrait, wx_open_id, |
| | | wx_union_id, wx_portrait, create_time, |
| | | update_time) |
| | | values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{identifyCode,jdbcType=VARCHAR}, |
| | | #{nickName,jdbcType=VARCHAR}, #{portrait,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, |
| | | #{alipayUid,jdbcType=VARCHAR}, #{alipayPortrait,jdbcType=VARCHAR}, #{wxOpenId,jdbcType=VARCHAR}, |
| | | #{wxUnionId,jdbcType=VARCHAR}, #{wxPortrait,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <delete id="deleteByPrimaryKey" |
| | | parameterType="java.lang.Long">delete from user_info where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.daylucky.pojo.DO.UserInfo">insert into user_info (id, app_id, identify_code, nick_name, portrait, mobile, alipay_uid, alipay_portrait, wx_open_id, wx_union_id, wx_portrait, create_time, update_time,alipay_nick_name,type,state,state_desc) values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{identifyCode,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{portrait,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{alipayUid,jdbcType=VARCHAR}, #{alipayPortrait,jdbcType=VARCHAR}, #{wxOpenId,jdbcType=VARCHAR}, #{wxUnionId,jdbcType=VARCHAR}, #{wxPortrait,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{alipayNickName,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{stateDesc,jdbcType=VARCHAR})</insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.daylucky.pojo.DO.UserInfo"> |
| | | insert into user_info |
| | | parameterType="com.ks.daylucky.pojo.DO.UserInfo">insert into user_info |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="appId != null"> |
| | | app_id, |
| | | </if> |
| | | <if test="identifyCode != null"> |
| | | identify_code, |
| | | </if> |
| | | <if test="nickName != null"> |
| | | nick_name, |
| | | </if> |
| | | <if test="portrait != null"> |
| | | portrait, |
| | | </if> |
| | | <if test="mobile != null"> |
| | | mobile, |
| | | </if> |
| | | <if test="alipayUid != null"> |
| | | alipay_uid, |
| | | </if> |
| | | <if test="alipayPortrait != null"> |
| | | alipay_portrait, |
| | | </if> |
| | | <if test="wxOpenId != null"> |
| | | wx_open_id, |
| | | </if> |
| | | <if test="wxUnionId != null"> |
| | | wx_union_id, |
| | | </if> |
| | | <if test="wxPortrait != null"> |
| | | wx_portrait, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | update_time, |
| | | </if> |
| | | <if test="id != null">id,</if> |
| | | <if test="appId != null">app_id,</if> |
| | | <if test="identifyCode != null">identify_code,</if> |
| | | <if test="nickName != null">nick_name,</if> |
| | | <if test="portrait != null">portrait,</if> |
| | | <if test="mobile != null">mobile,</if> |
| | | <if test="alipayUid != null">alipay_uid,</if> |
| | | <if test="alipayPortrait != null">alipay_portrait,</if> |
| | | <if test="wxOpenId != null">wx_open_id,</if> |
| | | <if test="wxUnionId != null">wx_union_id,</if> |
| | | <if test="wxPortrait != null">wx_portrait,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="alipayNickName != null">alipay_nick_name,</if> |
| | | <if test="type != null">type,</if> |
| | | <if test="state != null">state,</if> |
| | | <if test="stateDesc != null">state_desc,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null"> |
| | | #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="identifyCode != null"> |
| | | #{identifyCode,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="nickName != null"> |
| | | #{nickName,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="portrait != null"> |
| | | #{portrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="mobile != null"> |
| | | #{mobile,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="alipayUid != null"> |
| | | #{alipayUid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="alipayPortrait != null"> |
| | | #{alipayPortrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxOpenId != null"> |
| | | #{wxOpenId,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxUnionId != null"> |
| | | #{wxUnionId,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxPortrait != null"> |
| | | #{wxPortrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="appId != null">#{appId,jdbcType=BIGINT},</if> |
| | | <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if> |
| | | <if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if> |
| | | <if test="mobile != null">#{mobile,jdbcType=VARCHAR},</if> |
| | | <if test="alipayUid != null">#{alipayUid,jdbcType=VARCHAR},</if> |
| | | <if test="alipayPortrait != null">#{alipayPortrait,jdbcType=VARCHAR},</if> |
| | | <if test="wxOpenId != null">#{wxOpenId,jdbcType=VARCHAR},</if> |
| | | <if test="wxUnionId != null">#{wxUnionId,jdbcType=VARCHAR},</if> |
| | | <if test="wxPortrait != null">#{wxPortrait,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="alipayNickName != null">#{alipayNickName,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.daylucky.pojo.DO.UserInfo"> |
| | | update user_info |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.daylucky.pojo.DO.UserInfo">update user_info |
| | | <set> |
| | | <if test="appId != null"> |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="identifyCode != null"> |
| | | identify_code = #{identifyCode,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="nickName != null"> |
| | | nick_name = #{nickName,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="portrait != null"> |
| | | portrait = #{portrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="mobile != null"> |
| | | mobile = #{mobile,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="alipayUid != null"> |
| | | alipay_uid = #{alipayUid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="alipayPortrait != null"> |
| | | alipay_portrait = #{alipayPortrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxOpenId != null"> |
| | | wx_open_id = #{wxOpenId,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxUnionId != null"> |
| | | wx_union_id = #{wxUnionId,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="wxPortrait != null"> |
| | | wx_portrait = #{wxPortrait,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="appId != null">app_id = #{appId,jdbcType=BIGINT},</if> |
| | | <if test="identifyCode != null">identify_code = #{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="nickName != null">nick_name = #{nickName,jdbcType=VARCHAR},</if> |
| | | <if test="portrait != null">portrait = #{portrait,jdbcType=VARCHAR},</if> |
| | | <if test="mobile != null">mobile = #{mobile,jdbcType=VARCHAR},</if> |
| | | <if test="alipayUid != null">alipay_uid = #{alipayUid,jdbcType=VARCHAR},</if> |
| | | <if test="alipayPortrait != null">alipay_portrait = #{alipayPortrait,jdbcType=VARCHAR},</if> |
| | | <if test="wxOpenId != null">wx_open_id = #{wxOpenId,jdbcType=VARCHAR},</if> |
| | | <if test="wxUnionId != null">wx_union_id = #{wxUnionId,jdbcType=VARCHAR},</if> |
| | | <if test="wxPortrait != null">wx_portrait = #{wxPortrait,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="alipayNickName !=null">alipay_nick_name =#{alipayNickName,jdbcType=VARCHAR},</if> |
| | | <if test="type !=null">type =#{type,jdbcType=INTEGER},</if> |
| | | <if test="state !=null">state =#{state,jdbcType=INTEGER},</if> |
| | | <if test="stateDesc !=null">state_desc =#{stateDesc,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.daylucky.pojo.DO.UserInfo"> |
| | | update user_info |
| | | set app_id = #{appId,jdbcType=BIGINT}, |
| | | identify_code = #{identifyCode,jdbcType=VARCHAR}, |
| | | nick_name = #{nickName,jdbcType=VARCHAR}, |
| | | portrait = #{portrait,jdbcType=VARCHAR}, |
| | | mobile = #{mobile,jdbcType=VARCHAR}, |
| | | alipay_uid = #{alipayUid,jdbcType=VARCHAR}, |
| | | alipay_portrait = #{alipayPortrait,jdbcType=VARCHAR}, |
| | | wx_open_id = #{wxOpenId,jdbcType=VARCHAR}, |
| | | wx_union_id = #{wxUnionId,jdbcType=VARCHAR}, |
| | | wx_portrait = #{wxPortrait,jdbcType=VARCHAR}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.ks.daylucky.pojo.DO.UserInfo">update user_info set app_id = #{appId,jdbcType=BIGINT}, identify_code = #{identifyCode,jdbcType=VARCHAR}, nick_name = #{nickName,jdbcType=VARCHAR}, portrait = #{portrait,jdbcType=VARCHAR}, mobile = #{mobile,jdbcType=VARCHAR}, alipay_uid = #{alipayUid,jdbcType=VARCHAR}, alipay_portrait = #{alipayPortrait,jdbcType=VARCHAR}, wx_open_id = #{wxOpenId,jdbcType=VARCHAR}, wx_union_id = #{wxUnionId,jdbcType=VARCHAR}, wx_portrait = #{wxPortrait,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} ,alipay_nick_name =#{alipayNickName,jdbcType=VARCHAR} ,type =#{type,jdbcType=INTEGER} ,state =#{state,jdbcType=INTEGER} ,state_desc =#{stateDesc,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}</update> |
| | | </mapper> |
| | |
| | | |
| | | |
| | | <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief"> |
| | | <ul class="layui-tab-title"> |
| | | <li class="layui-this">活动内容</li> |
| | | <li>活动奖品</li> |
| | | <li>开奖设置</li> |
| | | <li>广告设置</li> |
| | | </ul> |
| | | <div class="layui-tab-content"> |
| | | <div class="layui-tab-item layui-show"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-header">活动内容</div> |
| | | <div class="layui-card-body"> |
| | | <div class="layui-row"> |
| | | <form class="layui-form"> |
| | | <div class="layui-form-item"> |
| | |
| | | </div> |
| | | |
| | | </div> |
| | | <div class="layui-tab-item"> |
| | | </div> |
| | | |
| | | <div class="layui-card"> |
| | | <div class="layui-card-header">活动奖品</div> |
| | | <div class="layui-card-body"> |
| | | <!--奖品列表 --> |
| | | |
| | | <form class="layui-form award-form"> |
| | |
| | | </button> |
| | | </div> |
| | | </form> |
| | | |
| | | </div> |
| | | <div class="layui-tab-item">开奖设置</div> |
| | | <div class="layui-tab-item">广告设置</div> |
| | | </div> |
| | | |
| | | |
| | | <div class="layui-card"> |
| | | <div class="layui-card-header">开奖设置</div> |
| | | <div class="layui-card-body"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-card"> |
| | | <div class="layui-card-header">广告设置</div> |
| | | <div class="layui-card-body"> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | |
| | | <button class="layui-btn layui-btn-warm layui-btn-lg" id="submit" lay-submit="">立即提交</button> |
| | | </div> |
| | | |
| | |
| | | package com.ks; |
| | | |
| | | import com.ks.daylucky.pojo.DO.Announcement; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.yeshi.utils.generater.mybatis.MyBatisMapperUtil; |
| | | import org.yeshi.utils.generater.mybatis.ColumnParseUtil; |
| | | |
| | | public class MyBatisTest { |
| | | |
| | | @Test |
| | | public void test() { |
| | | MyBatisMapperUtil.createMapper(Announcement.class); |
| | | ColumnParseUtil.parseColumn(UserInfo.class,"D:\\workspace\\DayLucky\\service-daylucky\\src\\main\\resources\\mapper\\UserInfoMapper.xml"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky; |
| | | |
| | | import com.ks.daylucky.exception.UserInfoException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.yeshi.utils.HtmlToolUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @SpringBootTest |
| | | public class UserTest { |
| | | Logger logger = LoggerFactory.getLogger(UserTest.class); |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Test |
| | | public void addDemoUser() { |
| | | List<String[]> list = HtmlToolUtil.parseSQLYogExportHtmData("C:\\Users\\Administrator\\Desktop\\草稿\\test.htm", 3); |
| | | for (String[] sts : list) { |
| | | logger.info(sts[1] + ":" + sts[2]); |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.setNickName(sts[1]); |
| | | userInfo.setPortrait(sts[2]); |
| | | userInfo.setIdentifyCode(UUID.randomUUID().toString()); |
| | | userInfo.setAppId(4L); |
| | | userInfo.setType(UserInfo.TYPE_VIRTUAL); |
| | | userInfo.setState(UserInfo.STATE_LOGINED); |
| | | try { |
| | | userInfoService.addUserInfo(userInfo); |
| | | } catch (UserInfoException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | </dependency> |
| | | |
| | | <!--devtools热部署--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-devtools</artifactId> |
| | | <optional>true</optional> |
| | | <scope>true</scope> |
| | | </dependency> |
| | | <!--<dependency>--> |
| | | <!--<groupId>org.springframework.boot</groupId>--> |
| | | <!--<artifactId>spring-boot-devtools</artifactId>--> |
| | | <!--<optional>true</optional>--> |
| | | <!--<scope>true</scope>--> |
| | | <!--</dependency>--> |
| | | <dependency> |
| | | <groupId>com.ks</groupId> |
| | | <artifactId>facade-lucky</artifactId> |
New file |
| | |
| | | package com.ks.lucky.aspect; |
| | | |
| | | import com.ks.lucky.manager.RedisManager; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.DefaultParameterNameDiscoverer; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.expression.EvaluationContext; |
| | | import org.springframework.expression.Expression; |
| | | import org.springframework.expression.ExpressionParser; |
| | | import org.springframework.expression.spel.standard.SpelExpressionParser; |
| | | import org.springframework.expression.spel.support.StandardEvaluationContext; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Method; |
| | | |
| | | @Component |
| | | @Aspect |
| | | @Order(4) |
| | | public class RedisCacheAspect { |
| | | Logger logger = LoggerFactory.getLogger(RedisCacheAspect.class); |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | |
| | | private ExpressionParser parser = new SpelExpressionParser(); |
| | | |
| | | private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer(); |
| | | |
| | | /** |
| | | * 获取表达的值 |
| | | * |
| | | * @param spELString |
| | | * @param joinPoint |
| | | * @return |
| | | */ |
| | | public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) { |
| | | MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); |
| | | String[] paramNames = nameDiscoverer.getParameterNames(methodSignature.getMethod()); |
| | | Expression expression = parser.parseExpression(spELString); |
| | | EvaluationContext context = new StandardEvaluationContext(); |
| | | Object[] args = joinPoint.getArgs(); |
| | | for (int i = 0; i < args.length; i++) { |
| | | context.setVariable(paramNames[i], args[i]); |
| | | } |
| | | return expression.getValue(context).toString(); |
| | | } |
| | | |
| | | private String getRedisKey(RedisCache cache, ProceedingJoinPoint joinPoint) { |
| | | return cache.cate() + "#" + generateKeyBySpEL(cache.key(), joinPoint); |
| | | } |
| | | |
| | | private String getRedisKey(RedisCacheEvict cache, ProceedingJoinPoint joinPoint) { |
| | | String key = cache.key(); |
| | | String keyPrefix = cache.keyPrefix(); |
| | | String cacheKey = cache.cate() + "#" + (StringUtil.isNullOrEmpty(key) ? generateKeyBySpEL(keyPrefix, joinPoint) : generateKeyBySpEL(key, joinPoint)); |
| | | return cacheKey; |
| | | } |
| | | |
| | | @Around("execution(public * com.ks.lucky.service..*.*(..))") |
| | | public Object requestSerializable(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method targetMethod = methodSignature.getMethod(); |
| | | |
| | | |
| | | Method realMethod = null; |
| | | RedisCache redisCache = null; |
| | | RedisCacheEvict[] redisCacheEvicts = null; |
| | | try { |
| | | realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(joinPoint.getSignature().getName(), |
| | | targetMethod.getParameterTypes()); |
| | | if (realMethod.isAnnotationPresent(RedisCache.class)) { |
| | | redisCache = realMethod.getAnnotation(RedisCache.class); |
| | | } else { |
| | | redisCacheEvicts = realMethod.getAnnotationsByType(RedisCacheEvict.class); |
| | | } |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } catch (SecurityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (redisCache != null) { |
| | | String cacheKey = getRedisKey(redisCache, joinPoint); |
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) { |
| | | try { |
| | | Object result = redisManager.getDataFromRedis(cacheKey); |
| | | if (result != null) { |
| | | return result; |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("redis获取缓存出错", e.getMessage(), "key:" + cacheKey); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Object object = joinPoint.proceed(); |
| | | //不异常 |
| | | if (realMethod != null) { |
| | | //不缓存空值 |
| | | if (redisCache != null && object != null) { |
| | | String cacheKey = getRedisKey(redisCache, joinPoint); |
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) { |
| | | try { |
| | | redisManager.setDataToRedis(cacheKey, object, redisCache.second()); |
| | | } catch (Exception e) { |
| | | logger.error("redis保存缓存数据出错", e.getMessage(), "key:" + cacheKey); |
| | | } |
| | | } |
| | | } else if (redisCacheEvicts != null && redisCacheEvicts.length > 0) { |
| | | for (RedisCacheEvict redisCacheEvict : redisCacheEvicts) { |
| | | String key = redisCacheEvict.key(); |
| | | String cacheKey = getRedisKey(redisCacheEvict, joinPoint); |
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) { |
| | | try { |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | redisManager.remove(cacheKey); |
| | | } else { |
| | | redisManager.removePrefix(cacheKey); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("redis清除缓存数据出错", e.getMessage(), "key:" + cacheKey); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return object; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | class ParamsTypeValue { |
| | | Class<?> type; |
| | | Object value; |
| | | |
| | | public ParamsTypeValue(Class<?> type, Object value) { |
| | | this.type = type; |
| | | this.value = value; |
| | | } |
| | | |
| | | public ParamsTypeValue() { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.config; |
| | | |
| | | import org.apache.commons.pool2.impl.GenericObjectPoolConfig; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import redis.clients.jedis.JedisPool; |
| | | |
| | | @Configuration |
| | | public class RedisConfig { |
| | | Logger log = LoggerFactory.getLogger(RedisConfig.class); |
| | | |
| | | @Value("${redis.host}") |
| | | private String host; |
| | | |
| | | @Value("${redis.port}") |
| | | private int port; |
| | | |
| | | @Value("${redis.password}") |
| | | private String password; |
| | | |
| | | @Value("${redis.timeout}") |
| | | private int timeout; |
| | | |
| | | @Value("${redis.jedis.pool.max-wait}") |
| | | private int maxWait; |
| | | |
| | | @Value("${redis.jedis.pool.max-idle}") |
| | | private int maxIdle; |
| | | |
| | | @Value("${redis.jedis.pool.max-total}") |
| | | private int maxTotal; |
| | | @Value("${redis.database}") |
| | | private int database; |
| | | |
| | | |
| | | @Bean |
| | | public JedisPool jedisPool() { |
| | | GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); |
| | | poolConfig.setMaxWaitMillis(maxWait); |
| | | poolConfig.setMaxIdle(maxIdle); |
| | | poolConfig.setMaxTotal(maxTotal); |
| | | JedisPool pool = new JedisPool(poolConfig, host, port, timeout, password, database); |
| | | return pool; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public List<LuckyActivityImage> listByActivityId(Long activityId, LuckyActivityImage.LuckyImageType type, int page, int pageSize) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("activityId").is(activityId).and("type").is(type)); |
| | | query.addCriteria(new Criteria().andOperator(Criteria.where("activityId").is(activityId), Criteria.where("type").is(type.name()))); |
| | | query.skip((page - 1) * pageSize); |
| | | query.limit(pageSize); |
| | | query.with(Sort.by(Sort.Order.desc("weight"))); |
| | |
| | | package com.ks.lucky.manager; |
| | | |
| | | import com.ks.lib.common.util.RedisUtil; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.SerializeUtil; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.params.SetParams; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | public class RedisManager { |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | private JedisPool jedisPool; |
| | | |
| | | private RedisUtil redisUtil = null; |
| | | public Jedis getJedis() { |
| | | Jedis jedis = jedisPool.getResource(); |
| | | return jedis; |
| | | } |
| | | |
| | | //注入Redis监听 |
| | | public void setRedisUtil() { |
| | | if (redisUtil == null) { |
| | | redisUtil = new RedisUtil(redisTemplate); |
| | | private void setString(String key, String value, int seconds) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.setex(key, seconds, value); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 缓存字符串 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | private void setString(String key, String value) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.set(key, value); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void remove(String... keys) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.del(keys); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | public void removePrefix(String... keys) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | for (String key : keys) { |
| | | Set<String> sets = jedis.keys(key + "*"); |
| | | if (sets != null) { |
| | | for (String k : sets) { |
| | | jedis.del(k); |
| | | } |
| | | } |
| | | } |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | private String getString(String key) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | return jedis.get(key); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void get() { |
| | | redisUtil.get(""); |
| | | public String getCommonString(String key) { |
| | | return getString(key); |
| | | } |
| | | |
| | | public void cacheCommonString(String key, String value, int seconds) { |
| | | setString(key, value, seconds); |
| | | } |
| | | |
| | | public void cacheCommonString(String key, String value) { |
| | | setString(key, value); |
| | | } |
| | | |
| | | /** |
| | | * 从redis缓存中查询,反序列化 |
| | | * |
| | | * @param redisKey |
| | | * @return |
| | | */ |
| | | public Object getDataFromRedis(String redisKey) { |
| | | //查询 |
| | | Jedis jedis = jedisPool.getResource(); |
| | | try { |
| | | byte[] result = jedis.get(redisKey.getBytes()); |
| | | |
| | | //如果查询没有为空 |
| | | if (null == result) { |
| | | return null; |
| | | } |
| | | |
| | | //查询到了,反序列化 |
| | | return SerializeUtil.unSerialize(result); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将数据库中查询到的数据放入redis |
| | | * |
| | | * @param redisKey |
| | | * @param obj |
| | | */ |
| | | public void setDataToRedis(String redisKey, Object obj, Integer seconds) { |
| | | |
| | | //序列化 |
| | | byte[] bytes = SerializeUtil.serialize(obj); |
| | | |
| | | SetParams params = null; |
| | | if (seconds != null) { |
| | | params = new SetParams().nx().ex(seconds); |
| | | } |
| | | //存入redis |
| | | Jedis jedis = jedisPool.getResource(); |
| | | try { |
| | | jedis.set(redisKey.getBytes(), bytes, params); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | * 赞助商ID |
| | | */ |
| | | public Long sponsorId; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | public String sort; |
| | | |
| | | /** |
| | | * 是否人数已满 |
| | |
| | | */ |
| | | public List<Integer> stateList; |
| | | |
| | | public List<Long> excludeActivityIds; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityImage; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @param image |
| | | * @throws ParamsException |
| | | */ |
| | | public void add(LuckyActivityImage image) throws ParamsException; |
| | | public void add(@Valid LuckyActivityImage image) throws ParamsException; |
| | | |
| | | /** |
| | | * @param activityId |
| | |
| | | * 删除 |
| | | * |
| | | * @param id |
| | | * @param activityId |
| | | */ |
| | | public void deleteById(String id); |
| | | public void deleteById(String id,Long activityId); |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardMaterial; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.query.ActivityAwardQuery; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.yeshi.utils.StringUtil; |
| | |
| | | ActivityAwardQuery query = new ActivityAwardQuery(); |
| | | query.activityId = award.getActivityId(); |
| | | query.level = award.getLevel(); |
| | | query.count=1; |
| | | query.count = 1; |
| | | List<LuckyActivityAwards> list = luckyActivityAwardsMapper.list(query); |
| | | if (list != null && list.size() > 0) { |
| | | throw new LuckyActivityAwardException(LuckyActivityAwardException.CODE_EXIST, "同等级的奖项已经存在"); |
| | |
| | | * @param award |
| | | * @throws LuckyActivityAwardException |
| | | */ |
| | | public void updateAward(LuckyActivityAwards award) throws LuckyActivityAwardException { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-awards", key = "'getAwardList-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-awards", key = "'getAwardDetail-'+#award.id") |
| | | public void updateAward(LuckyActivityAwards award, Long activityId) throws LuckyActivityAwardException { |
| | | if (award.getId() == null) { |
| | | throw new LuckyActivityAwardException(LuckyActivityAwardException.CODE_PARAMS_NOT_ENOUGH, "参数不完整"); |
| | | } |
| | |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | @RedisCache(cate = "activity-awards", key = "'getAwardList-'+#activityId", second = 3600) |
| | | public List<LuckyActivityAwards> getAwardList(Long activityId) { |
| | | ActivityAwardQuery query = new ActivityAwardQuery(); |
| | | query.activityId = activityId; |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RedisCache(cate = "activity-awards", key = "'getAwardDetail-'+#id", second = 3600) |
| | | public LuckyActivityAwards getAwardDetail(Long id) { |
| | | LuckyActivityAwards awards = luckyActivityAwardsMapper.selectByPrimaryKey(id); |
| | | if (!StringUtil.isNullOrEmpty(awards.getMaterialId())) { |
| | |
| | | * @param id |
| | | */ |
| | | |
| | | public void deleteAward(Long id) { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-awards", key = "'getAwardList-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-awards", key = "'getAwardDetail-'+#id") |
| | | public void deleteAward(Long id, Long activityId) { |
| | | LuckyActivityAwards awards = getAwardDetail(id); |
| | | if (awards.getMaterial() != null) { |
| | | luckyActivityAwardMaterialDao.delete(awards.getMaterial().getId()); |
| | |
| | | import com.ks.lucky.dao.LuckyActivityImageDao; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityImage; |
| | | import com.ks.lucky.service.LuckyActivityImageService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Resource |
| | | private LuckyActivityImageDao luckyActivityImageDao; |
| | | |
| | | |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#image.activityId") |
| | | @RedisCacheEvict(cate = "activity-image", key = "'listUrlByActivityId-'+#image.activityId+'-'+#image.type") |
| | | @RedisCacheEvict(cate = "activity-image", key = "'listByActivityId-'+#image.activityId+'-'+#image.type") |
| | | @Validated |
| | | @Override |
| | | public void add(@Valid LuckyActivityImage image) throws ParamsException { |
| | |
| | | luckyActivityImageDao.save(image); |
| | | } |
| | | |
| | | @RedisCache(cate = "activity-image", key = "'listByActivityId-'+#activityId+'-'+#type", second = 1800) |
| | | @Override |
| | | public List<LuckyActivityImage> listByActivityId(Long activityId, LuckyActivityImage.LuckyImageType type) { |
| | | |
| | | return luckyActivityImageDao.listByActivityId(activityId, type, 1, 100); |
| | | } |
| | | |
| | | @RedisCache(cate = "activity-image", key = "'listUrlByActivityId-'+#activityId+'-'+#type", second = 1800) |
| | | @Override |
| | | public List<String> listUrlByActivityId(Long activityId, LuckyActivityImage.LuckyImageType type) { |
| | | List<LuckyActivityImage> list = listByActivityId(activityId, type); |
| | |
| | | return urlList; |
| | | } |
| | | |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#image.activityId") |
| | | @RedisCacheEvict(cate = "activity-image", keyPrefix = "'listUrlByActivityId-'+#image.activityId") |
| | | @RedisCacheEvict(cate = "activity-image", keyPrefix = "'listByActivityId-'+#image.activityId") |
| | | @Override |
| | | public void deleteById(String id) { |
| | | public void deleteById(String id, Long activityId) { |
| | | luckyActivityImageDao.delete(id); |
| | | } |
| | | |
| | |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyMQException; |
| | | import com.ks.lucky.mapper.LuckyActivityMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityOpenInfo; |
| | | import com.ks.lucky.pojo.DO.LuckyMQ; |
| | | import com.ks.lucky.pojo.DO.*; |
| | | import com.ks.lucky.pojo.DTO.ActivityMQMsg; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityStateChangeMsgDTO; |
| | | import com.ks.lucky.service.LuckyActivityImageService; |
| | | import com.ks.lucky.service.LuckyMQService; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import com.ks.lucky.util.mq.LuckyMQFactory; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Component |
| | |
| | | |
| | | @Resource |
| | | private LuckyMQService luckyMQService; |
| | | @Resource |
| | | private LuckyActivityImageService luckyActivityImageService; |
| | | @Resource |
| | | private LuckyActivitySponsorInfoManager luckyActivitySponsorInfoManager; |
| | | @Resource |
| | | private LuckyActivityAwardManager luckyActivityAwardManager; |
| | | |
| | | |
| | | @RedisCache(cate = "activity", key = "'activity-detail-'+#id", second = 3600) |
| | | public LuckyActivity getActivityDetail(Long id) { |
| | | LuckyActivity activity = luckyActivityMapper.selectByPrimaryKey(id); |
| | | if (activity == null) { |
| | | return null; |
| | | } |
| | | |
| | | //加载图片信息 |
| | | List<LuckyActivityImage> bannerList = luckyActivityImageService.listByActivityId(id, LuckyActivityImage.LuckyImageType.banner); |
| | | activity.setBannerList(bannerList); |
| | | |
| | | //加载开奖信息 |
| | | LuckyActivityOpenInfo openInfo = luckyActivityOpenInfoManager.getOpenInfo(activity.getId()); |
| | | activity.setOpenInfo(openInfo); |
| | | |
| | | //加载赞助信息 |
| | | LuckyActivitySponsorInfo sponsorInfo = luckyActivitySponsorInfoManager.getSponsorInfo(activity.getId()); |
| | | if (sponsorInfo != null) { |
| | | sponsorInfo = luckyActivitySponsorInfoManager.getSponsorInfoDetail(sponsorInfo.getId()); |
| | | } |
| | | activity.setSponsorInfo(sponsorInfo); |
| | | |
| | | |
| | | //加载奖项信息 |
| | | List<LuckyActivityAwards> awardsList = luckyActivityAwardManager.getAwardList(activity.getId()); |
| | | List<LuckyActivityAwards> awardsDetailList = new ArrayList<>(); |
| | | if (awardsList != null) { |
| | | for (LuckyActivityAwards awards : awardsList) { |
| | | awards = luckyActivityAwardManager.getAwardDetail(awards.getId()); |
| | | if (awards != null) { |
| | | awardsDetailList.add(awards); |
| | | } |
| | | } |
| | | } |
| | | activity.setAwardsList(awardsDetailList); |
| | | |
| | | return activity; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * @param count |
| | | * @throws LuckyActivityException |
| | | */ |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addJoinCount(Long activityId, int count) throws LuckyActivityException { |
| | | LuckyActivity luckyActivity = luckyActivityMapper.selectByPrimaryKeyForUpdate(activityId); |
| | |
| | | * |
| | | * @param activityId |
| | | */ |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | public void startUpActivity(Long activityId) throws LuckyActivityException, LuckyMQException { |
| | | LuckyActivity luckyActivity = luckyActivityMapper.selectByPrimaryKeyForUpdate(activityId); |
| | | if (luckyActivity == null) { |
| | |
| | | * @param force 是否强制结束 |
| | | * @param remarks |
| | | */ |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void finishActivity(Long activityId, boolean force, String remarks) throws LuckyActivityException, LuckyMQException { |
| | | LuckyActivity activity = luckyActivityMapper.selectByPrimaryKeyForUpdate(activityId); |
| | |
| | | * @param state |
| | | * @param stateRemarks |
| | | */ |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setState(Long activityId, int state, String stateRemarks) { |
| | | LuckyActivity activity = new LuckyActivity(); |
| | |
| | | activity.setState(state); |
| | | activity.setStateRemarks(stateRemarks); |
| | | activity.setUpdateTime(new Date()); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(activity); |
| | | updateSelectiveByPrimaryKey(activity); |
| | | CMQManager.getInstance().publishActivityStateChangeMsg(new ActivityStateChangeMsgDTO(activityId, state, stateRemarks, activity.getUpdateTime())); |
| | | } |
| | | |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activity.id") |
| | | public void updateSelectiveByPrimaryKey(LuckyActivity activity) { |
| | | if (activity.getUpdateTime() == null) { |
| | | activity.setUpdateTime(new Date()); |
| | | } |
| | | luckyActivityMapper.updateByPrimaryKeySelective(activity); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityOpenInfoException; |
| | | import com.ks.lucky.mapper.LuckyActivityOpenInfoMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityOpenInfo; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | |
| | | * @param openInfo |
| | | * @throws LuckyActivityOpenInfoException |
| | | */ |
| | | public void updateOpenInfo(LuckyActivityOpenInfo openInfo) throws LuckyActivityOpenInfoException { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate="activity-openinfo",key = "'getOpenInfo-'+#activityId") |
| | | @RedisCacheEvict(cate="activity-openinfo",key = "'getOpenInfoDetail-'+#openInfo.id") |
| | | public void updateOpenInfo(LuckyActivityOpenInfo openInfo,Long activityId) throws LuckyActivityOpenInfoException { |
| | | openInfo.setUpdateTime(new Date()); |
| | | luckyActivityOpenInfoMapper.updateByPrimaryKeySelective(openInfo); |
| | | } |
| | |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | @RedisCache(cate="activity-openinfo",key = "'getOpenInfo-'+#activityId",second = 1800) |
| | | public LuckyActivityOpenInfo getOpenInfo(Long activityId) { |
| | | |
| | | |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RedisCache(cate="activity-openinfo",key = "'getOpenInfoDetail-'+#id",second = 1800) |
| | | public LuckyActivityOpenInfo getOpenInfoDetail(Long id) { |
| | | |
| | | return luckyActivityOpenInfoMapper.selectByPrimaryKey(id); |
| | |
| | | * |
| | | * @param id |
| | | */ |
| | | |
| | | public void deleteOpenInfo(Long id) { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate="activity-openinfo",key = "'getOpenInfo-'+#activityId") |
| | | @RedisCacheEvict(cate="activity-openinfo",key = "'getOpenInfoDetail-'+#id") |
| | | public void deleteOpenInfo(Long id,Long activityId) { |
| | | luckyActivityOpenInfoMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | |
| | | import com.ks.lucky.pojo.DO.LuckySponsorAd; |
| | | import com.ks.lucky.pojo.DO.LuckySponsors; |
| | | import com.ks.lucky.query.ActivitySponsorInfoQuery; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | |
| | | public void addSponsorInfo(LuckyActivitySponsorInfo sponsorInfo) throws LuckyActivitySponsorInfoException { |
| | | ActivitySponsorInfoQuery query = new ActivitySponsorInfoQuery(); |
| | | query.activityId = sponsorInfo.getActivityId(); |
| | | query.start=0; |
| | | query.count=1; |
| | | query.start = 0; |
| | | query.count = 1; |
| | | |
| | | List<LuckyActivitySponsorInfo> list = luckyActivitySponsorInfoMapper.list(query); |
| | | if (list != null && list.size() > 0) { |
| | |
| | | * @param sponsorInfo |
| | | * @throws LuckyActivitySponsorInfoException |
| | | */ |
| | | public void updateSponsorInfo(LuckyActivitySponsorInfo sponsorInfo) throws LuckyActivitySponsorInfoException { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-sponsorinfo", key = "'getSponsorInfo-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-sponsorinfo", key = "'getSponsorInfoDetail-'+#sponsorInfo.id") |
| | | public void updateSponsorInfo(LuckyActivitySponsorInfo sponsorInfo, Long activityId) throws LuckyActivitySponsorInfoException { |
| | | luckyActivitySponsorInfoMapper.updateByPrimaryKeySelective(sponsorInfo); |
| | | } |
| | | |
| | |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | @RedisCache(cate = "activity-sponsorinfo", key = "'getSponsorInfo-'+#activityId") |
| | | public LuckyActivitySponsorInfo getSponsorInfo(Long activityId) { |
| | | ActivitySponsorInfoQuery query = new ActivitySponsorInfoQuery(); |
| | | query.activityId = activityId; |
| | | query.start=0; |
| | | query.count=1; |
| | | query.start = 0; |
| | | query.count = 1; |
| | | List<LuckyActivitySponsorInfo> list = luckyActivitySponsorInfoMapper.list(query); |
| | | if (list != null && list.size() > 0) { |
| | | return list.get(0); |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RedisCache(cate = "activity-sponsorinfo", key = "'getSponsorInfoDetail-'+#id") |
| | | public LuckyActivitySponsorInfo getSponsorInfoDetail(Long id) { |
| | | LuckyActivitySponsorInfo info = luckyActivitySponsorInfoMapper.selectByPrimaryKey(id); |
| | | if (info == null) { |
| | |
| | | * |
| | | * @param id |
| | | */ |
| | | |
| | | public void deleteSponsorInfo(Long id) { |
| | | @RedisCacheEvict(cate = "activity", key = "'activity-detail-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-sponsorinfo", key = "'getSponsorInfo-'+#activityId") |
| | | @RedisCacheEvict(cate = "activity-sponsorinfo", key = "'getSponsorInfoDetail-'+#id") |
| | | public void deleteSponsorInfo(Long id, Long activityId) { |
| | | luckySponsorsMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void updateAward(LuckyActivityAwards award) throws LuckyActivityAwardException { |
| | | luckyActivityAwardManager.updateAward(award); |
| | | LuckyActivityAwards old = luckyActivityAwardManager.getAwardDetail(award.getId()); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | |
| | | luckyActivityAwardManager.updateAward(award, old.getActivityId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void deleteAward(Long id) { |
| | | luckyActivityAwardManager.deleteAward(id); |
| | | LuckyActivityAwards old = luckyActivityAwardManager.getAwardDetail(id); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | luckyActivityAwardManager.deleteAward(id, old.getActivityId()); |
| | | } |
| | | } |
| | |
| | | private LuckyActivityMapper luckyActivityMapper; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void assist(Long activityId, Long appId, String uid, String targetUid, ActivityJoinAssistEvent eventKey, int weight) throws LuckyActivityException, LuckyActivityJoinAssistException { |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isAssisted(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey) { |
| | | public boolean isAssisted(@NotNull Long joinId, @NotNull Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey) { |
| | | ActivityJoinAssistQuery query = new ActivityJoinAssistQuery(); |
| | | query.joinId = joinId; |
| | | query.appId = appId; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey) { |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotNull Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey) { |
| | | ActivityJoinAssistQuery query = new ActivityJoinAssistQuery(); |
| | | query.joinId = joinId; |
| | | query.appId = appId; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void join(Long activityId, Long appId, String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException { |
| | | public void join(Long activityId, Long appId, String uid, Integer weight, JoinInfo joinInfo,int userType) throws LuckyActivityException, LuckyActivityJoinException { |
| | | luckyActivityManager.canJoin(activityId); |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record != null) { |
| | |
| | | record.setCreateTime(new Date()); |
| | | record.setJoinInfo(joinInfo.toString()); |
| | | record.setUid(uid); |
| | | record.setUserType(LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | record.setUserType(userType); |
| | | record.setWeight(weight); |
| | | record.setCreateTime(new Date()); |
| | | luckyActivityJoinRecordMapper.insertSelective(record); |
| | |
| | | |
| | | @Override |
| | | public void updateOpenInfo(LuckyActivityOpenInfo openInfo) throws LuckyActivityOpenInfoException { |
| | | luckyActivityOpenInfoManager.updateOpenInfo(openInfo); |
| | | |
| | | LuckyActivityOpenInfo old = luckyActivityOpenInfoManager.getOpenInfoDetail(openInfo.getId()); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | |
| | | luckyActivityOpenInfoManager.updateOpenInfo(openInfo, old.getActivityId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void deleteOpenInfo(Long id) { |
| | | luckyActivityOpenInfoManager.deleteOpenInfo(id); |
| | | LuckyActivityOpenInfo old = luckyActivityOpenInfoManager.getOpenInfoDetail(id); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | luckyActivityOpenInfoManager.deleteOpenInfo(id, old.getActivityId()); |
| | | } |
| | | } |
| | |
| | | @Resource |
| | | private LuckyActivityMapper luckyActivityMapper; |
| | | |
| | | |
| | | @Resource |
| | | private LuckyActivityOpenInfoManager luckyActivityOpenInfoManager; |
| | | |
| | |
| | | update.setState(LuckyActivity.STATE_PRE_OPENED); |
| | | update.setStateRemarks("预开奖成功"); |
| | | update.setUpdateTime(new Date()); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(update); |
| | | luckyActivityManager.updateSelectiveByPrimaryKey(update); |
| | | //添加消息 |
| | | CMQManager.getInstance().addActivityMsg(new ActivityMQMsg(activityId, ActivityMQMsg.TYPE_OPEN_SHOW, new Date())); |
| | | } |
| | |
| | | update.setUpdateTime(new Date()); |
| | | update.setState(LuckyActivity.STATE_OPENED); |
| | | update.setStateRemarks("已开奖"); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(update); |
| | | luckyActivityManager.updateSelectiveByPrimaryKey(update); |
| | | |
| | | //先设置所有记录未中奖 |
| | | luckyActivityJoinManager.setActivityAllJoinerUnDraw(activityId); |
| | |
| | | import com.ks.lucky.service.LuckyActivityImageService; |
| | | import com.ks.lucky.service.LuckyMQService; |
| | | import com.ks.lucky.service.impl.*; |
| | | import com.ks.lucky.util.annotation.RedisCache; |
| | | import com.ks.lucky.util.annotation.RedisCacheEvict; |
| | | import com.ks.lucky.util.mq.LuckyMQFactory; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | query.appId = appId; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.sort = "start_time desc"; |
| | | query.sortList = Arrays.asList(new String[]{"actual_start_time desc"}); |
| | | return luckyActivityMapper.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivity> getActivityList(Long appId, Long sponsorId, List<Integer> stateList, List<Long> excludeActivityIds, String key, int page, int pageSize) { |
| | | |
| | | |
| | | ActivityDaoQuery query = new ActivityDaoQuery(); |
| | | query.stateList = stateList; |
| | | query.key = key; |
| | | query.sponsorId = sponsorId; |
| | | query.excludeActivityIds = excludeActivityIds; |
| | | query.appId = appId; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.sortList = Arrays.asList(new String[]{"actual_start_time desc"}); |
| | | return luckyActivityMapper.list(query); |
| | | } |
| | | |
| | |
| | | query.key = key; |
| | | query.sponsorId = sponsorId; |
| | | query.appId = appId; |
| | | |
| | | return luckyActivityMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countActivity(Long appId, Long sponsorId, List<Integer> stateList, String key, List<Long> excludeActivityIds) { |
| | | ActivityDaoQuery query = new ActivityDaoQuery(); |
| | | query.stateList = stateList; |
| | | query.key = key; |
| | | query.sponsorId = sponsorId; |
| | | query.appId = appId; |
| | | query.excludeActivityIds = excludeActivityIds; |
| | | |
| | | return luckyActivityMapper.count(query); |
| | | } |
| | |
| | | |
| | | //检查活动状态 |
| | | if (activity.getState() != LuckyActivity.STATE_NOT_PUBLISH) { |
| | | throw new LuckyActivityException(1, "活动已发布"); |
| | | throw new LuckyActivityException(1, "活动未处于审核成功状态"); |
| | | } |
| | | //检查开奖信息 |
| | | LuckyActivityOpenInfo openInfo = luckyActivityOpenInfoManager.getOpenInfo(activity.getId()); |
| | |
| | | |
| | | @Override |
| | | public LuckyActivity getActivityDetail(Long id) { |
| | | LuckyActivity activity = luckyActivityMapper.selectByPrimaryKey(id); |
| | | if (activity == null) { |
| | | return null; |
| | | } |
| | | |
| | | //加载图片信息 |
| | | List<LuckyActivityImage> bannerList = luckyActivityImageService.listByActivityId(id, LuckyActivityImage.LuckyImageType.banner); |
| | | activity.setBannerList(bannerList); |
| | | |
| | | //加载开奖信息 |
| | | LuckyActivityOpenInfo openInfo = luckyActivityOpenInfoManager.getOpenInfo(activity.getId()); |
| | | activity.setOpenInfo(openInfo); |
| | | |
| | | //加载赞助信息 |
| | | LuckyActivitySponsorInfo sponsorInfo = luckyActivitySponsorInfoManager.getSponsorInfo(activity.getId()); |
| | | if (sponsorInfo != null) { |
| | | sponsorInfo = luckyActivitySponsorInfoManager.getSponsorInfoDetail(sponsorInfo.getId()); |
| | | } |
| | | activity.setSponsorInfo(sponsorInfo); |
| | | |
| | | |
| | | //加载奖项信息 |
| | | List<LuckyActivityAwards> awardsList = luckyActivityAwardManager.getAwardList(activity.getId()); |
| | | List<LuckyActivityAwards> awardsDetailList = new ArrayList<>(); |
| | | if (awardsList != null) { |
| | | for (LuckyActivityAwards awards : awardsList) { |
| | | awards = luckyActivityAwardManager.getAwardDetail(awards.getId()); |
| | | if (awards != null) { |
| | | awardsDetailList.add(awards); |
| | | } |
| | | } |
| | | } |
| | | activity.setAwardsList(awardsDetailList); |
| | | |
| | | return activity; |
| | | return luckyActivityManager.getActivityDetail(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivity> getActivityDetail(List<Long> ids) { |
| | | List<LuckyActivity> activityList = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | LuckyActivity luckyActivity = getActivityDetail(id); |
| | | LuckyActivity luckyActivity = luckyActivityManager.getActivityDetail(id); |
| | | activityList.add(luckyActivity); |
| | | } |
| | | return activityList; |
| | |
| | | } |
| | | |
| | | activity.setUpdateTime(new Date()); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(activity); |
| | | luckyActivityManager.updateSelectiveByPrimaryKey(activity); |
| | | } |
| | | |
| | | @Override |
| | |
| | | query.appId = appId; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.sort = "actual_start_time desc"; |
| | | query.sortList = Arrays.asList(new String[]{"actual_start_time desc"}); |
| | | |
| | | query.stateList = Arrays.asList(new Integer[]{ |
| | | LuckyActivity.STATE_STARTED, |
| | |
| | | LuckyActivity.STATE_OPENED, |
| | | }); |
| | | |
| | | |
| | | return luckyActivityMapper.list(query); |
| | | List<LuckyActivity> list = luckyActivityMapper.list(query); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Validated |
| | | @Override |
| | | public Long addSponsorInfo(LuckyActivitySponsorInfo sponsorInfo) throws ParamsException,LuckyActivitySponsorInfoException { |
| | | public Long addSponsorInfo(LuckyActivitySponsorInfo sponsorInfo) throws ParamsException, LuckyActivitySponsorInfoException { |
| | | luckyActivitySponsorInfoManager.addSponsorInfo(sponsorInfo); |
| | | return sponsorInfo.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void updateSponsorInfo(LuckyActivitySponsorInfo sponsorInfo) throws LuckyActivitySponsorInfoException { |
| | | luckyActivitySponsorInfoManager.updateSponsorInfo(sponsorInfo); |
| | | LuckyActivitySponsorInfo old = luckyActivitySponsorInfoManager.getSponsorInfoDetail(sponsorInfo.getId()); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | |
| | | luckyActivitySponsorInfoManager.updateSponsorInfo(sponsorInfo, old.getActivityId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void deleteSponsorInfo(Long id) { |
| | | luckyActivitySponsorInfoManager.deleteSponsorInfo(id); |
| | | LuckyActivitySponsorInfo old = luckyActivitySponsorInfoManager.getSponsorInfoDetail(id); |
| | | if (old == null) { |
| | | return; |
| | | } |
| | | luckyActivitySponsorInfoManager.deleteSponsorInfo(id, old.getActivityId()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.util.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | @Documented |
| | | @Target(ElementType.METHOD) |
| | | @Inherited |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface RedisCache { |
| | | String key(); |
| | | //分类 |
| | | String cate(); |
| | | //默认1分钟 |
| | | int second() default 60; |
| | | } |
New file |
| | |
| | | package com.ks.lucky.util.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | @Documented |
| | | @Target(ElementType.METHOD) |
| | | @Inherited |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Repeatable(RedisCacheEvicts.class) |
| | | public @interface RedisCacheEvict { |
| | | String key() default ""; |
| | | String keyPrefix() default ""; |
| | | //分类 |
| | | String cate(); |
| | | } |
New file |
| | |
| | | package com.ks.lucky.util.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | @Documented |
| | | @Target(ElementType.METHOD) |
| | | @Inherited |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface RedisCacheEvicts { |
| | | RedisCacheEvict[] value(); |
| | | } |
| | |
| | | port: 27016 |
| | | database: lucky |
| | | authentication-database: admin |
| | | redis: |
| | | host: 192.168.3.253 |
| | | port: 6379 |
| | | password: '123456' |
| | | timeout: 5000 |
| | | jedis: |
| | | pool: |
| | | max-wait: 10000 |
| | | max-idle: 200 |
| | | max-active: 1024 |
| | | database: 3 |
| | | |
| | | datasource: |
| | | url: jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ks_lucky |
| | | url: jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ks_lucky?&useTimezone=true&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: Yeshi2016@ |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl |
| | | |
| | | redis: |
| | | host: 193.112.34.40 |
| | | port: 6379 |
| | | password: 'weikou2014' |
| | | timeout: 5000 |
| | | jedis: |
| | | pool: |
| | | max-wait: 10000 |
| | | max-idle: 200 |
| | | max-total: 1024 |
| | | database: 4 |
| | | |
| | | dubbo: |
| | | application: |
| | | name: lucky-provider |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://192.168.3.253:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://192.168.3.136:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | | port: 20882 |
| | | port: 20900 |
| | | scan: |
| | | base-packages: com.ks.lucky.service.impl.remote |
| | | provider: |
| | |
| | | com: |
| | | ks: |
| | | lucky: |
| | | mapper: debug |
| | | mapper: debug |
| | | org.springframework.data.mongodb.core: DEBUG |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | <!-- 非模板--> |
| | | <sql id="listWhere"> |
| | | <if test="query.activityId!=null">and activity_id=#{query.activityId}</if> |
| | | <if test="query.level!=null">and `level`=#{query.level}</if> |
| | | <if test="query.minCreateTime!=null">and create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>create_time</if> |
| | | </sql> |
| | |
| | | from lucky_activity_awards where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">#{item}</foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> ${item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="ActivityAssistInfoResultMap" type="com.ks.lucky.pojo.DTO.ActivityAssistFriend"> |
| | | <resultMap id="ActivityAssistInfoResultMap" type="com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo"> |
| | | <result column="uid" jdbcType="VARCHAR" property="uid"/> |
| | | <result column="app_id" jdbcType="BIGINT" property="appId"/> |
| | | <result column="weight" jdbcType="INTEGER" property="weight"/> |
| | | <result column="join_id" jdbcType="BIGINT" property="joinId"/> |
| | | <result column="join_id" jdbcType="BIGINT" property="joinerId"/> |
| | | <association property="eventList" column="join_id" |
| | | javaType="com.ks.lucky.pojo.DO.ActivityJoinAssistEvent" |
| | | select="selectEventkeyWithJoinId"></association> |
| | |
| | | from lucky_activity_join_assist where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">#{item}</foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> ${item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | |
| | | from lucky_activity_join_record where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">#{item}</foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> ${item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | |
| | | <result column="pre_start_time" property="preStartTime" jdbcType="TIMESTAMP"/> |
| | | <result column="actual_start_time" property="actualStartTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count,current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time,actual_open_time, create_time, update_time,`state`,pre_start_time,actual_start_time</sql> |
| | | <sql id="Base_Column_List">id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count,current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time,actual_open_time, create_time, update_time,pre_start_time,actual_start_time</sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity where id = #{id,jdbcType=BIGINT} |
| | |
| | | <delete id="deleteByPrimaryKey" |
| | | parameterType="java.lang.Long">delete from lucky_activity where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivity">insert into lucky_activity (id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count, current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time, actual_open_time,create_time, update_time,id,`state`,pre_start_time,actual_start_time) values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{sponsorId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{materialPoster,jdbcType=VARCHAR}, #{materialTagImage,jdbcType=VARCHAR}, #{material,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{maxPersonCount,jdbcType=INTEGER}, #{currentPersonCount,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{stateRemarks,jdbcType=VARCHAR}, #{preFinishTime,jdbcType=TIMESTAMP}, #{actualFinishTime,jdbcType=TIMESTAMP}, #{preOpenTime,jdbcType=TIMESTAMP}, #{actualOpenTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{id,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{preStartTime,jdbcType=TIMESTAMP},#{actualStartTime,jdbcType=TIMESTAMP})</insert> |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivity">insert into lucky_activity (id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count, current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time, actual_open_time,create_time, update_time,id,pre_start_time,actual_start_time) values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{sponsorId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{materialPoster,jdbcType=VARCHAR}, #{materialTagImage,jdbcType=VARCHAR}, #{material,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{maxPersonCount,jdbcType=INTEGER}, #{currentPersonCount,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{stateRemarks,jdbcType=VARCHAR}, #{preFinishTime,jdbcType=TIMESTAMP}, #{actualFinishTime,jdbcType=TIMESTAMP}, #{preOpenTime,jdbcType=TIMESTAMP}, #{actualOpenTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{id,jdbcType=BIGINT},#{preStartTime,jdbcType=TIMESTAMP},#{actualStartTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivity">insert into lucky_activity |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="actualOpenTime != null">actual_open_time,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="state != null">`state`,</if> |
| | | <if test="preStartTime != null">pre_start_time,</if> |
| | | <if test="actualStartTime != null">actual_start_time,</if> |
| | | </trim> |
| | |
| | | <if test="actualOpenTime != null">#{actualOpenTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER}</if> |
| | | <if test="preStartTime != null">#{preStartTime,jdbcType=TIMESTAMP}</if> |
| | | <if test="actualStartTime != null">#{actualStartTime,jdbcType=TIMESTAMP}</if> |
| | | <if test="preStartTime != null">#{preStartTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="actualStartTime != null">#{actualStartTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivity">update lucky_activity |
| | |
| | | <if test="actualOpenTime != null">actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state !=null">`state` =#{state,jdbcType=INTEGER},</if> |
| | | <if test="preStartTime !=null">pre_start_time =#{preStartTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="actualStartTime !=null">actual_start_time =#{actualStartTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lucky.pojo.DO.LuckyActivity"> |
| | | update lucky_activity set app_id = #{appId,jdbcType=BIGINT}, sponsor_id = #{sponsorId,jdbcType=BIGINT}, `name` = #{name,jdbcType=VARCHAR}, material_poster = #{materialPoster,jdbcType=VARCHAR}, material_tag_image = #{materialTagImage,jdbcType=VARCHAR}, material_ = #{material,jdbcType=VARCHAR}, `desc` = #{desc,jdbcType=VARCHAR}, max_person_count = #{maxPersonCount,jdbcType=INTEGER}, current_person_count = #{currentPersonCount,jdbcType=INTEGER}, state = #{state,jdbcType=INTEGER}, state_remarks = #{stateRemarks,jdbcType=VARCHAR}, pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP}, actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP}, pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP}, actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} ,`state` =#{state,jdbcType=INTEGER} ,pre_start_time =#{preStartTime,jdbcType=TIMESTAMP} ,actual_start_time =#{actualStartTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update> |
| | | update lucky_activity set app_id = #{appId,jdbcType=BIGINT}, sponsor_id = #{sponsorId,jdbcType=BIGINT}, `name` = #{name,jdbcType=VARCHAR}, material_poster = #{materialPoster,jdbcType=VARCHAR}, material_tag_image = #{materialTagImage,jdbcType=VARCHAR}, material_ = #{material,jdbcType=VARCHAR}, `desc` = #{desc,jdbcType=VARCHAR}, max_person_count = #{maxPersonCount,jdbcType=INTEGER}, current_person_count = #{currentPersonCount,jdbcType=INTEGER}, state = #{state,jdbcType=INTEGER}, state_remarks = #{stateRemarks,jdbcType=VARCHAR}, pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP}, actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP}, pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP}, actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} ,pre_start_time =#{preStartTime,jdbcType=TIMESTAMP} ,actual_start_time =#{actualStartTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update> |
| | | <sql id="queryWhere"> |
| | | <if test="query.key!=null">and `name` like '${query.key}%'</if> |
| | | <if test="query.appId!=null">and app_id=#{query.appId}</if> |
| | |
| | | <foreach collection="query.stateList" item="state" open=" and (" close=")" separator=" or ">state=#{state} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="query.excludeActivityIds!=null"> |
| | | <foreach collection="query.excludeActivityIds" item="activityId" open=" and (" close=")" separator=" and ">id!=#{activityId} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="query.minCreateTime!=null">and create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>create_time</if> |
| | | <if test="query.minStartTime!=null">and pre_start_time>=#{query.minStartTime}</if> |
| | |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity where 1=1 |
| | | <include refid="queryWhere"/> |
| | | <if test="query.sort!=null">order by #{query.sort}</if> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | <select id="count" resultType="java.lang.Long">select count(*) from lucky_activity where 1=1 |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | <if test="query.state!=null"> |
| | | and state=#{query.state} |
| | | </if> |
| | | <if test="query.uid!=null"> |
| | | and uid=#{query.uid} |
| | | </if> |
| | | <if test="query.activityId!=null"> |
| | | and activity_id=#{query.activityId} |
| | | </if> |
| | | |
| | | <if test="query.minPreSendTime!=null"> |
| | | and pre_send_time>=#{query.minPreSendTime} |
| | | </if> |
| | | |
| | | <if test="query.maxPreSendTime!=null"> |
| | | and #{query.maxPreSendTime}>pre_send_time |
| | | and <![CDATA[ pre_send_time<#{query.maxPreSendTime} ]]> |
| | | </if> |
| | | |
| | | <if test="query.minActualSendTime!=null"> |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | |
| | | import com.ks.lucky.pojo.DTO.ActivityAwardParams; |
| | | import com.ks.lucky.pojo.DTO.sponsorad.AlipayLifeAdInfo; |
| | | import com.ks.lucky.remote.service.*; |
| | | import com.ks.lucky.service.LuckyActivityImageService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.yeshi.utils.StringUtil; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @SpringBootTest |
| | | public class ActivityTest { |
| | |
| | | |
| | | @Resource |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | |
| | | @Resource |
| | | private LuckyActivityImageService luckyActivityImageService; |
| | | |
| | | @Resource |
| | | private LuckyActivityOpenInfoService luckyActivityOpenInfoService; |
| | |
| | | private LuckySponsorAdService luckySponsorAdService; |
| | | |
| | | |
| | | private final Long ACTIVITY_ID = 7L; |
| | | |
| | | @Test |
| | | public void getActivityDetail() { |
| | | LuckyActivity activity = luckyActivityService.getActivityDetail(7L); |
| | |
| | | activity.setMaxPersonCount(100); |
| | | activity.setPreStartTime(new Date()); |
| | | activity.setPreFinishTime(new Date()); |
| | | activity.setMaterialPoster("http://"); |
| | | activity.setMaterialPoster("https://img.zcool.cn/community/0319c445f99483711013ee04df8e7e5.jpg@260w_195h_1c_1e_1o_100sh.jpg"); |
| | | activity.setSponsorId(1L); |
| | | activity.setName("测试活动1"); |
| | | |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void addBanner() { |
| | | |
| | | String[] urls = new String[]{ |
| | | "https://img.zcool.cn/community/0105f35fe82c9c11013fdcc72b3767.jpg@260w_195h_1c_1e_1o_100sh.jpg", "https://img.zcool.cn/community/01d99f5fe81bd711013ee04d0b9fcc.jpg@260w_195h_1c_1e_1o_100sh.jpg", "https://img.zcool.cn/community/016d825fe5c1a411013fdcc72c68a4.jpg" |
| | | |
| | | }; |
| | | for (String url : urls) { |
| | | LuckyActivityImage image = new LuckyActivityImage(); |
| | | image.setType(LuckyActivityImage.LuckyImageType.banner); |
| | | image.setActivityId(ACTIVITY_ID); |
| | | image.setUrl(url); |
| | | try { |
| | | luckyActivityImageService.add(image); |
| | | } catch (ParamsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void addOpenInfo() { |
| | | LuckyActivityOpenInfo openInfo = new LuckyActivityOpenInfo(); |
| | | openInfo.setActivityId(7L); |
| | | openInfo.setMinPersonCount(80); |
| | | openInfo.setActivityId(ACTIVITY_ID); |
| | | openInfo.setMinPersonCount(3); |
| | | openInfo.setOpenType(LuckyActivityOpenInfo.OPEN_TYPE_PERSON); |
| | | try { |
| | | luckyActivityOpenInfoService.addOpenInfo(openInfo); |
| | |
| | | public void addSponsorInfo() { |
| | | LuckyActivitySponsorInfo info = new LuckyActivitySponsorInfo(); |
| | | info.setSponsorId(1L); |
| | | info.setSponsorAdId("1-1606811078760"); |
| | | info.setActivityId(7L); |
| | | info.setSponsorAdId("1-1609123351179"); |
| | | info.setActivityId(ACTIVITY_ID); |
| | | try { |
| | | luckyActivitySponsorInfoService.addSponsorInfo(info); |
| | | } catch (ParamsException e) { |
| | |
| | | |
| | | @Test |
| | | public void updateSponsorAd() { |
| | | LuckySponsorAd ad = luckySponsorAdService.getAdDetail("1-1606811078760"); |
| | | LuckySponsorAd ad = luckySponsorAdService.getAdDetail("1-1609123351179"); |
| | | AlipayLifeAdInfo adInfo = new AlipayLifeAdInfo(); |
| | | adInfo.setSceneId("48a5df949dd5406193dcdba81f0bb9fd"); |
| | | adInfo.setDesc("【车载香薰多选系列】大自然的味道,健康环保,持久淡香,采用调香环保配方,持久散发清新香味,有效清除难闻或残留异味,清新怡人,缓解压力,优雅别致~家里车上两用喔!"); |
| | |
| | | |
| | | @Test |
| | | public void addAwards() { |
| | | |
| | | LuckyActivityAwardMaterial material = new LuckyActivityAwardMaterial(); |
| | | material.setImgList(Arrays.asList(new String[]{"https://img.alicdn.com/bao/uploaded/i1/3257346636/O1CN01WxbaYp1ytKvvdyJKR_!!0-item_pic.jpg_220x220_.webp", "https://img.alicdn.com/bao/uploaded/i3/2453257123/O1CN01OtPz5g22UNoHitoNA_!!0-item_pic.jpg_220x220_.webp"})); |
| | | material.setType(LuckyActivityAwardMaterial.ActivityAwardMaterialType.alipayRedPackage); |
| | |
| | | |
| | | LuckyActivityAwards awards = new LuckyActivityAwards(); |
| | | awards.setMaterialId(material.getId()); |
| | | awards.setActivityId(7L); |
| | | awards.setAwardWay(LuckyActivityAwards.AWARD_WAY_DIVIDE); |
| | | awards.setAwardParams(new ActivityAwardParams(ActivityAwardParams.ActivityAwardTypeEnum.alipayRedPackage, new BigDecimal("100")).toString()); |
| | | awards.setCount(100); |
| | | awards.setLevel(0); |
| | | awards.setActivityId(ACTIVITY_ID); |
| | | awards.setAwardName("10元随机红包"); |
| | | awards.setAwardWay(LuckyActivityAwards.AWARD_WAY_RANDOM); |
| | | awards.setAwardParams(new ActivityAwardParams(ActivityAwardParams.ActivityAwardTypeEnum.alipayRedPackage, new BigDecimal("10")).toString()); |
| | | awards.setCount(2); |
| | | awards.setLevel(1); |
| | | |
| | | |
| | | try { |
| | |
| | | @Test |
| | | public void submitVerify() { |
| | | try { |
| | | luckyActivityService.submitVerify(7L); |
| | | luckyActivityService.submitVerify(ACTIVITY_ID); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void reject() { |
| | | try { |
| | | luckyActivityService.verifyActivity(7L, false, "测试拒绝"); |
| | | luckyActivityService.verifyActivity(ACTIVITY_ID, false, "测试拒绝"); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void pass() { |
| | | try { |
| | | luckyActivityService.verifyActivity(7L, true, "审核通过"); |
| | | luckyActivityService.verifyActivity(ACTIVITY_ID, true, "审核通过"); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void publish() { |
| | | try { |
| | | luckyActivityService.publishActivity(7L); |
| | | luckyActivityService.publishActivity(ACTIVITY_ID); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void cancel() { |
| | | try { |
| | | luckyActivityService.cancelPublish(7L, "主动取消发布"); |
| | | luckyActivityService.cancelPublish(ACTIVITY_ID, "主动取消发布"); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void start() { |
| | | try { |
| | | luckyActivityService.startActivity(7L, "手动开启"); |
| | | luckyActivityService.startActivity(ACTIVITY_ID, "手动开启"); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Test |
| | | public void forceStop() { |
| | | try { |
| | | luckyActivityService.forceFinishActivity(7L, "强制结束"); |
| | | luckyActivityService.forceFinishActivity(ACTIVITY_ID, "强制结束"); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void listActivityImages() { |
| | | Long id = 1000001L; |
| | | List<LuckyActivityImage> list = luckyActivityImageService.listByActivityId(id, LuckyActivityImage.LuckyImageType.banner); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lucky; |
| | | |
| | | import com.ks.lucky.job.MQJob; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @SpringBootTest |
| | | public class JobTest { |
| | | |
| | | @Resource |
| | | private MQJob mqJob; |
| | | |
| | | @Test |
| | | public void mqJob() { |
| | | try { |
| | | mqJob.sendMQ(""); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.pojo.DO.ActivityJoinAssistEvent; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.JoinInfo; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.UUID; |
| | | |
| | | @SpringBootTest |
| | | public class JoinTest { |
| | |
| | | |
| | | @Test |
| | | public void join() { |
| | | Long activityId = 7L; |
| | | Long appId = 10001L; |
| | | String uid = "123"; |
| | | JoinInfo joinInfo = JoinInfo.JoinInfoFactory.createAlipay("123123123123"); |
| | | try { |
| | | luckyActivityJoinService.join(activityId, appId, uid, null, joinInfo); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyActivityJoinException e) { |
| | | e.printStackTrace(); |
| | | Long activityId = 1000001L; |
| | | Long appId = 4L; |
| | | String uid = 4L + ""; |
| | | for (int i = 0; i < 100; i++) { |
| | | JoinInfo joinInfo = JoinInfo.JoinInfoFactory.createAlipay(UUID.randomUUID().toString()); |
| | | try { |
| | | luckyActivityJoinService.join(activityId, appId, (i + 10) + "", null, joinInfo, LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyActivityJoinException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | ActivityDaoQuery query = new ActivityDaoQuery(); |
| | | query.sponsorId = 1L; |
| | | query.stateList = Arrays.asList(new Integer[]{LuckyActivity.STATE_NOT_STARTED, LuckyActivity.STATE_VERIFY_REJECT}); |
| | | query.sort = "create_time desc"; |
| | | query.appId = 1L; |
| | | query.full = true; |
| | | query.start = 0; |