|
@@ -12,26 +12,51 @@ import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
|
+import com.yonge.cooleshow.common.enums.BizHttpStatus;
|
|
|
|
+import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
|
+import com.yonge.cooleshow.common.enums.UserStatusEnum;
|
|
|
|
+import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
import com.yonge.cooleshow.tenant.vo.TenantActivationCodeVo;
|
|
import com.yonge.cooleshow.tenant.vo.TenantActivationCodeVo;
|
|
|
|
+import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
|
+import com.yonge.toolset.utils.easyexcel.ErrMsg;
|
|
|
|
+import com.yonge.toolset.utils.easyexcel.ExcelDataReader;
|
|
|
|
+import com.yonge.toolset.utils.easyexcel.ExcelException;
|
|
|
|
+import com.yonge.toolset.utils.easyexcel.ExcelUtils;
|
|
|
|
+import com.yonge.toolset.utils.excel.POIUtil;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
import org.springframework.validation.annotation.Validated;
|
|
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.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -53,6 +78,9 @@ public class TenantActivationCodeController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private TenantInfoService tenantInfoService;
|
|
private TenantInfoService tenantInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TenantStaffService tenantStaffService;
|
|
|
|
+
|
|
@ApiOperation(value = "详情", notes = "机构激活码-根据详情ID查询单条, 传入id")
|
|
@ApiOperation(value = "详情", notes = "机构激活码-根据详情ID查询单条, 传入id")
|
|
// @GetMapping("/detail/{id}")
|
|
// @GetMapping("/detail/{id}")
|
|
public R<TenantActivationCodeVo.TenantActivationCode> detail(@PathVariable("id") Long id) {
|
|
public R<TenantActivationCodeVo.TenantActivationCode> detail(@PathVariable("id") Long id) {
|
|
@@ -95,6 +123,67 @@ public class TenantActivationCodeController extends BaseController {
|
|
return succeed();
|
|
return succeed();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping("/exportActiveCode")
|
|
|
|
+ @ApiOperation(value = "导出模板")
|
|
|
|
+ public void exportActiveCode(HttpServletResponse response) {
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
|
+ if (sysUser == null) {
|
|
|
|
+ throw new BizException("请登录");
|
|
|
|
+ }
|
|
|
|
+ Long tenantId = sysUser.getTenantId();
|
|
|
|
+
|
|
|
|
+ TenantActivationCodeWrapper.TenantActivationCodeQuery query =
|
|
|
|
+ new TenantActivationCodeWrapper.TenantActivationCodeQuery();
|
|
|
|
+ query.setTenantId(tenantId);
|
|
|
|
+ query.setActivationStatus(false);
|
|
|
|
+ query.setPage(1);
|
|
|
|
+ query.setRows(9999);
|
|
|
|
+ IPage<TenantActivationCodeWrapper.TenantActivationCode> queryInfo =
|
|
|
|
+ tenantActivationCodeService.selectPage(QueryInfo.getPage(query), query);
|
|
|
|
+ List<TenantActivationCodeWrapper.TenantActivationCode> rows = queryInfo.getRecords();
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
+ throw new BizException("没有可导出数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"激活码", "手机号"}, new String[]{
|
|
|
|
+ "activationCode", "activationPhone"}, rows);
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ response.setHeader("Content-Disposition", "attac:wq" +
|
|
|
|
+ "hment;filename=active_code-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ outputStream.flush();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("导出激活码异常", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/importActiveCode")
|
|
|
|
+ @ApiOperation(value = "导入", notes = "传入file")
|
|
|
|
+ public HttpResponseResult<List<ErrMsg>> importActiveCode(@RequestParam("file") MultipartFile file) {
|
|
|
|
+ if (null == file) {
|
|
|
|
+ return HttpResponseResult.failed("请上传文件");
|
|
|
|
+ }
|
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
|
+ }
|
|
|
|
+ TenantStaff tenantStaff = tenantStaffService.getByUserId(user.getId());
|
|
|
|
+ if (tenantStaff == null) {
|
|
|
|
+ return HttpResponseResult.failed("权限不足");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ ExcelDataReader<TenantActivationCodeWrapper.ImportTemplate> reader =
|
|
|
|
+ ExcelUtils.getReader(TenantActivationCodeWrapper.ImportTemplate.class, file);
|
|
|
|
+ tenantActivationCodeService.importActiveCode(reader.getDataList(), user.getTenantId(), user.getId());
|
|
|
|
+ return HttpResponseResult.succeed();
|
|
|
|
+ } catch (ExcelException e) {
|
|
|
|
+ return HttpResponseResult.failed(BizHttpStatus.IMPORT.getCode(), e.getErrMsgList(),
|
|
|
|
+ BizHttpStatus.IMPORT.getMsg());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value = "新增", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCode")
|
|
@ApiOperation(value = "新增", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCode")
|
|
// @PostMapping("/save")
|
|
// @PostMapping("/save")
|
|
public R<JSONObject> add(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCode tenantActivationCodeVo) {
|
|
public R<JSONObject> add(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCode tenantActivationCodeVo) {
|