瀏覽代碼

1.后端添加小组和激活码相关接口

yuanliang 1 年之前
父節點
當前提交
71b5351474

+ 36 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantActivationCodeController.java

@@ -2,12 +2,16 @@ package com.yonge.cooleshow.admin.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.tenant.vo.TenantActivationCodeVo;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.mybatis.support.PageUtil;
@@ -16,10 +20,12 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -36,9 +42,12 @@ public class TenantActivationCodeController extends BaseController {
     @Autowired
     private TenantAlbumPurchaseService tenantAlbumPurchaseService;
 
+    @Autowired
+    private TenantInfoService tenantInfoService;
 
     @ApiOperation(value = "查询分页", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeQuery")
     @PostMapping("/page")
+    @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/page')")
     public HttpResponseResult<PageInfo<TenantActivationCodeWrapper.TenantActivationCode>> page(
             @RequestBody TenantActivationCodeWrapper.TenantActivationCodeQuery query) {
 
@@ -64,4 +73,31 @@ public class TenantActivationCodeController extends BaseController {
         return succeed(pageInfo);
     }
 
+    @ApiOperation(value = "激活码发放", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeSend")
+    @PostMapping("/send")
+    @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/send')")
+    public HttpResponseResult<Boolean> send(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCodeSend send) {
+        tenantActivationCodeService.sendActivationCode(send.getTenantId(), send.getTenantAlbumPurchaseId(),
+                send.getActivationCodeList(),
+                send.getStudentIdList());
+        return succeed();
+    }
+
+    @ApiOperation(value = "激活码重发", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeSend")
+    @PostMapping("/resend")
+    @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/resend')")
+    public HttpResponseResult<Boolean> resend(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCodeResend send) {
+        tenantActivationCodeService.resend(send.getCode(), send.getUserId(), send.getTenantId(), send.getTenantAlbumPurchaseId());
+        return succeed();
+    }
+
+    @ApiOperation(value = "激活码发放取消", notes = "传入 激活码的ID")
+    @PostMapping("/sendCancel")
+    @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/sendCancel')")
+    public HttpResponseResult<Boolean> sendCancel(@Validated @RequestBody TenantActivationCodeVo.CodeSend codeSend) {
+        TenantActivationCode activationCode = tenantActivationCodeService.getById(codeSend.getId());
+        TenantInfo tenantInfo = tenantInfoService.getById(codeSend.getTenantId());
+        tenantActivationCodeService.sendCancel(tenantInfo, activationCode);
+        return succeed();
+    }
 }

+ 84 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantGroupController.java

@@ -1,21 +1,39 @@
 package com.yonge.cooleshow.admin.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.ImGroup;
+import com.yonge.cooleshow.biz.dal.entity.TenantGroup;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.TenantGroupService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupWrapper;
+import com.yonge.cooleshow.tenant.vo.TenantGroupVo;
+import com.yonge.toolset.base.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
+
 @Slf4j
 @Validated
 @RestController
@@ -26,6 +44,12 @@ public class TenantGroupController {
     @Autowired
     private TenantGroupService tenantGroupService;
 
+    @Resource
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private ImGroupService imGroupService;
+
     @ApiOperation(value = "查询分页", notes = "机构小组表- 传入 TenantGroupWrapper.TenantGroupQuery")
     @PreAuthorize("@pcs.hasPermissions('tenantGroup/page', {'BACKEND'})")
     @PostMapping("/page")
@@ -40,4 +64,64 @@ public class TenantGroupController {
         return R.from(tenantGroupService.adjustTenantGroup(adjustTenantGroup));
     }
 
+    @ApiOperation(value = "详情", notes = "机构小组表-根据详情ID查询单条, 传入id")
+    @GetMapping("/detail/{id}")
+    @PreAuthorize("@pcs.hasPermissions('tenantGroup/detail')")
+    public R<TenantGroupWrapper.TenantGroup> detail(@PathVariable("id") Long id) {
+        TenantGroup wrapper = tenantGroupService.detail(id);
+        if (wrapper == null) {
+            return R.from(new TenantGroupWrapper.TenantGroup());
+        }
+        TenantGroupWrapper.TenantGroup group = TenantGroupWrapper.TenantGroup.from(JSON.toJSONString(wrapper));
+        group.setImGroupExist(false);
+        if (StringUtils.isNotEmpty(wrapper.getImGroupId())) {
+            ImGroup imGroup = imGroupService.getById(wrapper.getImGroupId());
+            if (imGroup != null) {
+                group.setImGroupExist(true);
+            }
+        }
+        List<TenantGroupWrapper.TenantGroupMember> members =
+                tenantGroupService.queryGroupMember(wrapper.getTenantId(), id);
+        List<Long> userIds = members.stream().map(TenantGroupWrapper.TenantGroupMember::getUserId)
+                .collect(Collectors.toList());
+        group.setUserIds(userIds);
+        group.setGroupUserCount(members.size());
+        group.setUserList(members);
+        return R.from(group);
+    }
+
+    @ApiOperation(value = "新增", notes = "机构小组表- 传入 TenantGroupWrapper.TenantGroup")
+    @PostMapping("/save")
+    @PreAuthorize("@pcs.hasPermissions('tenantGroup/add')")
+    public R<JSONObject> add(@Validated @RequestBody TenantGroupVo.TenantGroup tenantGroup) {
+        Long tenantId = tenantGroup.getTenantId();
+        if (tenantId == null) {
+            throw new BizException("机构ID不能为空");
+        }
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        TenantGroupWrapper.TenantGroup group = TenantGroupWrapper.TenantGroup.from(tenantGroup.jsonString());
+        group.setCreateBy(sysUser.getId());
+        // 新增数据
+        tenantGroupService.add(group, tenantGroup.getImGroupCreate());
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "修改", notes = "机构小组表- 传入 TenantGroupWrapper.TenantGroup")
+    @PostMapping("/update")
+    @PreAuthorize("@pcs.hasPermissions('tenantGroup/update')")
+    public R<JSONObject> update(@Validated @RequestBody TenantGroupVo.TenantGroup tenantGroup) {
+        // 更新数据
+        tenantGroupService.update(TenantGroupWrapper.TenantGroup.from(tenantGroup.jsonString()), tenantGroup.getImGroupCreate());
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "删除", notes = "机构小组表- 传入id")
+    @PostMapping("/remove")
+    @PreAuthorize("@pcs.hasPermissions('tenantGroup/detail')")
+    public R<Boolean> remove(@RequestParam Long id) {
+
+        return R.from(tenantGroupService.delete(id));
+    }
 }

+ 20 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/vo/TenantActivationCodeVo.java

@@ -27,6 +27,9 @@ public class TenantActivationCodeVo {
         @NotNull(message = "专辑购买记录的ID不能为空")
         private Long tenantAlbumPurchaseId;
 
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
         @ApiModelProperty("激活码列表,批量发送时为空")
         private List<String> activationCodeList = new ArrayList<>();
 
@@ -45,6 +48,9 @@ public class TenantActivationCodeVo {
         @NotNull(message = "专辑购买记录的ID不能为空")
         private Long tenantAlbumPurchaseId;
 
+        @ApiModelProperty("结构ID")
+        private Long tenantId;
+
         @ApiModelProperty("激活码")
         @NotBlank(message = "激活码不能为空")
         private String code;
@@ -117,4 +123,18 @@ public class TenantActivationCodeVo {
         }
     }
 
+    @Data
+    @ApiModel("激活码发放")
+    public static class CodeSend {
+
+        @ApiModelProperty("机构ID")
+        @NotNull
+        private Long tenantId;
+
+        @ApiModelProperty("激活码ID")
+        @NotNull
+        private Long id;
+
+    }
+
 }

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantActivationCodeWrapper.java

@@ -76,6 +76,9 @@ public class TenantActivationCodeWrapper {
         @ApiModelProperty("订单号 订单详情专用")
         private String orderNo;
 
+        @ApiModelProperty("激活码")
+        private String activationCode;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }

+ 3 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantActivationCodeMapper.xml

@@ -66,6 +66,9 @@
             <if test="param.tenantGroupId != null">
                 and st.tenant_group_id_ = #{param.tenantGroupId}
             </if>
+            <if test="param.activationCode != null and param.activationCode.trim() != ''">
+                AND t.activation_code_ like concat('%',#{param.activationCode},'%')
+            </if>
         </where>
         order by t.activation_status_ asc, t.id_ desc
     </select>

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumPurchaseMapper.xml

@@ -31,7 +31,7 @@
         <where>
             <if test="param.keyword != null and param.keyword.trim() != ''">
                 AND (ta.name_ like concat('%',#{param.keyword},'%')
-                or t.purchase_quantity_ = #{param.keyword}
+                or t.purchase_quantity_ like concat('%',#{param.keyword},'%')
                 )
             </if>
             <if test="param.tenantId != null">