10 changed files with 248 additions and 8 deletions
@ -0,0 +1,59 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|||
import com.elink.esua.epdc.commons.tools.annotation.LoginUser; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.service.ActPhraseService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* APP常用语相关接口 |
|||
* |
|||
* @author wanggongfeng |
|||
* @date 2019/12/17 10:30 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("heart") |
|||
public class ApiActPhraseController { |
|||
|
|||
@Autowired |
|||
private ActPhraseService actPhraseService; |
|||
|
|||
/** |
|||
* 使用次数加一 |
|||
* |
|||
* @param tokenDto |
|||
* @param id |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author wanggongfeng |
|||
* @date 2019/12/13 14:41 |
|||
*/ |
|||
@PostMapping("phrase/sagenumAddOne") |
|||
public Result sagenumAddOneById(@LoginUser TokenDto tokenDto, @PathVariable("id") String id) { |
|||
ValidatorUtils.validateEntity(id); |
|||
return actPhraseService.sagenumAddOneById(id); |
|||
} |
|||
|
|||
/** |
|||
* 获取常用语列表 |
|||
* |
|||
* @param tokenDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author wanggongfeng |
|||
* @date 2019/12/13 14:41 |
|||
*/ |
|||
@PostMapping("phrase/getPhraseList") |
|||
public Result getPhraseList(@LoginUser TokenDto tokenDto) { |
|||
ValidatorUtils.validateEntity(tokenDto); |
|||
return actPhraseService.getPhraseList(); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.fallback.AppActPhraseFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
|
|||
/** |
|||
* |
|||
* 活动报名管理 |
|||
* |
|||
* @Author:wanggongfeng |
|||
* @Date:2019/12/16 17:36 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_HEART_SERVER, fallback = AppActPhraseFeignClientFallback.class) |
|||
public interface AppActPhraseFeignClient { |
|||
|
|||
/** |
|||
* 活动报名 |
|||
* |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@GetMapping("heart/appactphrase/sagenumAddOneById/{id}") |
|||
Result sagenumAddOneById(@PathVariable("id") String id); |
|||
|
|||
/** |
|||
* 取消活动报名 |
|||
* @return |
|||
*/ |
|||
@GetMapping("heart/appactphrase/getPhraseList") |
|||
Result getPhraseList(); |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.AppActPhraseFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Author:wanggongfeng |
|||
* @Date:2019/12/16 15:11 |
|||
*/ |
|||
@Component |
|||
public class AppActPhraseFeignClientFallback implements AppActPhraseFeignClient { |
|||
|
|||
@Override |
|||
public Result sagenumAddOneById(String id) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "sagenumAddOneById", id); |
|||
} |
|||
@Override |
|||
public Result getPhraseList() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getPhraseList"); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
|
|||
/** |
|||
* @author wanggongfeng |
|||
* @date 2019/12/17 9:50 |
|||
*/ |
|||
public interface ActPhraseService { |
|||
|
|||
/** |
|||
* 常用语使用次数加一 |
|||
* @param id |
|||
* @Author wanggongfeng |
|||
* @return |
|||
*/ |
|||
Result sagenumAddOneById(String id); |
|||
|
|||
/** |
|||
* redis获取常用语 |
|||
* @Author wanggongfeng |
|||
* @return |
|||
*/ |
|||
Result getPhraseList(); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.AppActPhraseFeignClient; |
|||
import com.elink.esua.epdc.service.ActPhraseService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
/** |
|||
* @author wanggongfeng |
|||
* @date 2019/12/16 17:50 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class ActPhraseServiceImpl implements ActPhraseService { |
|||
|
|||
@Autowired |
|||
private AppActPhraseFeignClient appActPhraseFeignClient; |
|||
|
|||
@Override |
|||
public Result sagenumAddOneById(String id) { |
|||
Result<Integer> dataResult = appActPhraseFeignClient.sagenumAddOneById(id); |
|||
return dataResult; |
|||
} |
|||
|
|||
@Override |
|||
public Result getPhraseList() { |
|||
Result<Integer> dataResult = appActPhraseFeignClient.getPhraseList(); |
|||
return dataResult; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.phrases.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity; |
|||
import com.elink.esua.epdc.modules.phrases.service.ActPhraseService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 常用语表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-11 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("appactphrase") |
|||
public class AppActPhraseController { |
|||
|
|||
@Autowired |
|||
private ActPhraseService actPhraseService; |
|||
|
|||
@GetMapping(value="sagenumAddOneById",produces = "text/plain;charset=UTF-8") |
|||
public Result sagenumAddOne(String id) { |
|||
actPhraseService.updateUsagenumAddOne(id); |
|||
return new Result().ok("使用次数加一成功"); |
|||
} |
|||
|
|||
@GetMapping(value="getPhraseList",produces = "text/plain;charset=UTF-8") |
|||
public Result getPhraseList() { |
|||
List<ActPhraseRedisEntity> object = actPhraseService.getPhraseList(); |
|||
return new Result().ok(object); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue