package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.AddBadgeFormDTO; import com.epmet.dto.form.BadgeAuditFormDTO; import com.epmet.dto.form.BadgeFormDTO; import com.epmet.dto.form.EditBadgeFormDTO; import com.epmet.dto.result.BadgeAuditRecordResultDTO; import com.epmet.dto.result.BadgeAuditingResultDTO; import com.epmet.dto.result.BadgeDetailResultDTO; import com.epmet.dto.result.BadgeListResultDTO; import com.epmet.redis.UserBadgeRedis; import com.epmet.service.BadgeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @author zhaoqifeng * @dscription * @date 2020/11/3 16:09 */ @RestController @RequestMapping("badge") public class BadgeController { @Autowired private BadgeService badgeService; /** * 徽章列表 * @author zhaoqifeng * @date 2020/11/4 14:27 * @param tokenDto * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("list") public Result> list(@LoginUser TokenDto tokenDto) { List result = badgeService.getList(tokenDto.getCustomerId()); return new Result>().ok(result); } /** * 添加徽章 * @author zhaoqifeng * @date 2020/11/4 14:27 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result */ @PostMapping("add") public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddBadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); badgeService.add(tokenDto, formDTO); return new Result(); } /** * 徽章详情 * @author zhaoqifeng * @date 2020/11/4 14:27 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result */ @PostMapping("detail") public Result detail(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.ManageGroup.class); BadgeDetailResultDTO result = badgeService.detail(tokenDto, formDTO); return new Result().ok(result); } /** * 修改 * @author zhaoqifeng * @date 2020/11/4 15:32 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result */ @PostMapping("edit") public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditBadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); badgeService.edit(tokenDto, formDTO); return new Result(); } /** * 删除徽章 * @author zhaoqifeng * @date 2020/11/4 15:34 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result */ @PostMapping("delete") public Result delete(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.ManageGroup.class); badgeService.deleteBadge(tokenDto, formDTO); return new Result(); } @PostMapping("test-cache") public Result testCache(){ badgeService.testCache(); return new Result(); } /** * 待审核列表 * @author zhaoqifeng * @date 2020/11/5 9:51 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("auditinglist") public Result> auditingList(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.AuditGroup.class); List result = badgeService.auditingList(tokenDto, formDTO); return new Result>().ok(result); } /** * 审核历史列表 * @author zhaoqifeng * @date 2020/11/5 10:59 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("auditrecord") public Result> auditRecord(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.AuditGroup.class); List result = badgeService.auditRecord(tokenDto, formDTO); return new Result>().ok(result); } /** * 审核 * @author zhaoqifeng * @date 2020/11/5 11:09 * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result */ @PostMapping("audit") public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); badgeService.audit(tokenDto, formDTO); return new Result(); } @Autowired private UserBadgeRedis redis; @PostMapping("compensation-mechanism") public Result compensationMechanism(@RequestParam("userId")String userId,@RequestParam("customerId")String customerId,@RequestParam("b1")String b1, @RequestParam("b2")String b2){ redis.pushOrRemoveUserBadge4List(userId,b1,customerId); redis.pushOrRemoveUserBadge4List(userId,b1,customerId); redis.pushOrRemoveUserBadge4List(userId,b1,customerId); redis.pushOrRemoveUserBadge4List(userId,b2,customerId); redis.batchClearUserBadgeCache(customerId); redis.obtainUserBadge2List(userId,customerId); return new Result(); } }