|
|
|
@ -3,11 +3,15 @@ package com.zh.project0512.controller.manage;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.zh.project0512.annotation.AdminCheckAuthorityAnnotation;
|
|
|
|
|
import com.zh.project0512.annotation.AdminTokenValid;
|
|
|
|
|
import com.zh.project0512.model.User;
|
|
|
|
|
import com.zh.project0512.model.UserAccount;
|
|
|
|
|
import com.zh.project0512.service.IUserAccountService;
|
|
|
|
|
import com.zh.project0512.service.IUserService;
|
|
|
|
|
import com.zh.project0512.utils.CustomUtil;
|
|
|
|
|
import com.zh.project0512.utils.ExcelUtil;
|
|
|
|
|
import com.zh.project0512.utils.MybatisPlusUtil;
|
|
|
|
|
import com.zh.project0512.utils.result.HttpStatusEnum;
|
|
|
|
|
import com.zh.project0512.utils.result.Result;
|
|
|
|
@ -15,14 +19,23 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.constraints.Max;
|
|
|
|
|
import javax.validation.constraints.Min;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -36,7 +49,8 @@ import java.time.LocalDateTime;
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/manage/userAccount")
|
|
|
|
|
public class UserAccountController {
|
|
|
|
|
|
|
|
|
|
@Value("${web.cdn}")
|
|
|
|
|
private String cdn;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IUserAccountService userAccountService;
|
|
|
|
|
|
|
|
|
@ -49,7 +63,7 @@ public class UserAccountController {
|
|
|
|
|
private int pageSize;
|
|
|
|
|
@Schema(title = "用户名")
|
|
|
|
|
private String name;
|
|
|
|
|
@Schema(title = "账号状态",description = "0审核中;1审核通过;2审核拒绝")
|
|
|
|
|
@Schema(title = "账号状态", description = "0审核中;1审核通过;2审核拒绝")
|
|
|
|
|
private Integer status;
|
|
|
|
|
@Schema(title = "部门id")
|
|
|
|
|
private Integer departmentId;
|
|
|
|
@ -60,11 +74,51 @@ public class UserAccountController {
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result list(@Validated @RequestBody ListUAParam param) {
|
|
|
|
|
QueryWrapper<UserAccount> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq(param.getStatus() != null,"t1.status", param.getStatus());
|
|
|
|
|
qw.eq(param.getName() != null,"t2.name", param.getName());
|
|
|
|
|
qw.eq(param.getDepartmentId() != null,"t3.departmentId", param.getDepartmentId());
|
|
|
|
|
qw.orderByDesc("updateAt","creatAt");
|
|
|
|
|
return Result.success(userAccountService.listAll(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()),qw));
|
|
|
|
|
qw.eq(param.getStatus() != null, "t1.status", param.getStatus());
|
|
|
|
|
qw.eq(param.getName() != null, "t2.name", param.getName());
|
|
|
|
|
qw.eq(param.getDepartmentId() != null, "t3.departmentId", param.getDepartmentId());
|
|
|
|
|
qw.orderByDesc("updateAt", "creatAt");
|
|
|
|
|
return Result.success(userAccountService.listAll(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "导出excel", description = "关联账号列表导出")
|
|
|
|
|
@GetMapping("/excel")
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public void excel(HttpServletResponse response, @Validated @RequestBody ListUAParam param) throws IOException {
|
|
|
|
|
//这是表头及格式
|
|
|
|
|
String[][] array = {
|
|
|
|
|
{"申请人", "部门", "第三方平台", "昵称", "手机号", "截图"},
|
|
|
|
|
{"userName", "departmentName", "platform", "name", "tel", "validImg"},
|
|
|
|
|
{"String", "String", "String", "String", "String", "String"}
|
|
|
|
|
};
|
|
|
|
|
QueryWrapper<UserAccount> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq(param.getStatus() != null, "t1.status", param.getStatus());
|
|
|
|
|
qw.eq(param.getName() != null, "t2.name", param.getName());
|
|
|
|
|
qw.eq(param.getDepartmentId() != null, "t3.departmentId", param.getDepartmentId());
|
|
|
|
|
qw.orderByDesc("updateAt", "creatAt");
|
|
|
|
|
IPage iPage = userAccountService.listAll(MybatisPlusUtil.SetNumPage(1, 10000), qw);
|
|
|
|
|
List<Map> records = iPage.getRecords();
|
|
|
|
|
for (Map m : records) {
|
|
|
|
|
if (m.get("validImg") != null) {
|
|
|
|
|
m.replace("validImg", cdn + m.get("validImg"));
|
|
|
|
|
}
|
|
|
|
|
//平台:1抖音;2快手;3朋友圈;4视频号
|
|
|
|
|
Integer platform = (Integer) m.get("platform");
|
|
|
|
|
if (platform != null) {
|
|
|
|
|
m.replace("platform",platform ==1?"抖音":(platform ==2?"快手":(platform ==3?"朋友圈":platform ==4?"朋友圈":null)) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Workbook wb = ExcelUtil.writeToExcelByList(array, iPage.getRecords());
|
|
|
|
|
OutputStream output = response.getOutputStream();
|
|
|
|
|
String fileName = "用户账号导出.xlsx";
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ";" + "filename*=utf-8''" + fileName);
|
|
|
|
|
wb.write(output);
|
|
|
|
|
output.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@ -76,7 +130,7 @@ public class UserAccountController {
|
|
|
|
|
@NotNull(message = "状态不能为空")
|
|
|
|
|
@Min(value = 1, message = "1审核通过;2审核拒绝")
|
|
|
|
|
@Max(value = 3, message = "1审核通过;2审核拒绝")
|
|
|
|
|
@Schema(title = "状态",description = "1审核通过;2审核拒绝")
|
|
|
|
|
@Schema(title = "状态", description = "1审核通过;2审核拒绝")
|
|
|
|
|
private Integer status;
|
|
|
|
|
@Schema(title = "拒绝原因")
|
|
|
|
|
private String reason;
|
|
|
|
@ -88,15 +142,15 @@ public class UserAccountController {
|
|
|
|
|
@AdminCheckAuthorityAnnotation(jurisdictionId = "14")
|
|
|
|
|
public Result valid(@Validated @RequestBody PassUAParam param) {
|
|
|
|
|
UserAccount ua = userAccountService.getById(param.getId());
|
|
|
|
|
if(ua ==null){
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"未找到指定账号");
|
|
|
|
|
if (ua == null) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到指定账号");
|
|
|
|
|
}
|
|
|
|
|
if(ua.getStatus() != 0){
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"账号状态不在审核中");
|
|
|
|
|
if (ua.getStatus() != 0) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "账号状态不在审核中");
|
|
|
|
|
}
|
|
|
|
|
UpdateWrapper<UserAccount> updateWrapper = new UpdateWrapper<>();
|
|
|
|
|
updateWrapper.eq("id", param.getId()).set("status",param.getStatus()).set("updateAt",LocalDateTime.now());
|
|
|
|
|
updateWrapper.set("reason",param.getStatus()==2?param.getReason():"");
|
|
|
|
|
updateWrapper.eq("id", param.getId()).set("status", param.getStatus()).set("updateAt", LocalDateTime.now());
|
|
|
|
|
updateWrapper.set("reason", param.getStatus() == 2 ? param.getReason() : "");
|
|
|
|
|
userAccountService.update(updateWrapper);
|
|
|
|
|
return Result.success("修改完成");
|
|
|
|
|
}
|
|
|
|
|