123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901 |
- package com.caimei.controller.admin.auth;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.annotation.CurrentUser;
- import com.caimei.annotation.Idempotent;
- import com.caimei.annotation.WebHooks;
- import com.caimei.components.RedisService;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.po.CmBrandAuthPo;
- import com.caimei.model.po.SysUser;
- import com.caimei.model.vo.*;
- import com.caimei.service.auth.AuthService;
- import com.caimei.utils.OSSUtils;
- import com.caimei.utils.SmsUtils;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.http.Consts;
- import org.apache.http.HttpEntity;
- import org.apache.http.NameValuePair;
- import org.apache.http.client.entity.UrlEncodedFormEntity;
- import org.apache.http.client.methods.CloseableHttpResponse;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.entity.ContentType;
- import org.apache.http.impl.client.CloseableHttpClient;
- import org.apache.http.impl.client.HttpClients;
- import org.apache.http.message.BasicNameValuePair;
- import org.apache.http.util.EntityUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.nio.charset.StandardCharsets;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * 供应商API
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
- @Api(tags = "认证机构API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/auth")
- public class AuthApi {
- private final AuthService authService;
- @Resource
- private RedisService redisService;
- /**
- * 授权列表
- */
- @ApiOperation("授权列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
- @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
- @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
- @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
- @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
- @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
- Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
- Integer shopAuditStatus, Integer sendStatus, String authCode,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
- if (null != sysUser && 1 != sysUser.getId()) {
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- } else if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, authCode, pageNum, pageSize);
- }
- /**
- * 授权列表
- * 1.7.4版本
- * 新加两个查询条件
- * <p>
- * name 商品名称
- * snCode 商品sn码
- **/
- @ApiOperation("授权列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
- @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
- @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
- @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
- @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
- @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/listAll")
- public ResponseJson<PageInfo<AuthVo>> getAuthListAll(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
- Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
- Integer shopAuditStatus, Integer sendStatus, String name, String snCode,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
- if (null != sysUser && 1 != sysUser.getId()) {
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- } else if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getAuthListAll(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, name, snCode, pageNum, pageSize);
- }
- @ApiOperation("机构下拉框列表")
- @GetMapping("/select")
- public ResponseJson<List<AuthVo>> getAuthSelectList(@CurrentUser SysUser sysUser) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getAuthSelectList(authUserId);
- }
- /**
- * 更新授权状态
- */
- @ApiOperation("更新授权状态")
- @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateAuthStatus(@RequestBody Map<String, Integer> params) {
- Integer authId = params.get("authId");
- Integer status = params.get("status");
- return authService.updateAuthStatus(authId, status);
- }
- /**
- * 删除授权
- */
- @ApiOperation("删除授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
- @PostMapping("/delete")
- public ResponseJson deleteAuth(@RequestBody Map<String, Integer> params) {
- Integer authId = params.get("authId");
- return authService.deleteAuth(authId);
- }
- /**
- * 授权机构回显数据
- */
- @ApiOperation("授权机构回显数据")
- @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
- @GetMapping("/form/data")
- public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
- return authService.getAuthFormData(authId);
- }
- /**
- * 添加/编辑授权
- */
- @ApiOperation("添加/编辑授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
- "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
- "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
- "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
- "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
- "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
- "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
- @PostMapping("/save")
- @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
- public ResponseJson saveAuth(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- Integer provinceId = paramsMap.getInteger("provinceId");
- Integer cityId = paramsMap.getInteger("cityId");
- Integer townId = paramsMap.getInteger("townId");
- String address = paramsMap.getString("address");
- String lngAndLat = paramsMap.getString("lngAndLat");
- String mobile = paramsMap.getString("mobile");
- String userMobile = paramsMap.getString("userMobile");
- String linkMan = paramsMap.getString("linkMan");
- String linkMobile = paramsMap.getString("linkMobile");
- Integer firstClubType = paramsMap.getInteger("firstClubType");
- Integer secondClubType = paramsMap.getInteger("secondClubType");
- String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
- Integer empNum = paramsMap.getInteger("empNum");
- String logo = paramsMap.getString("logo");
- String authCode = paramsMap.getString("authCode");
- String authDateStr = paramsMap.getString("authDate");
- SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
- Date authDate = null;
- if (StringUtils.isNotEmpty(authDateStr)) {
- authDate = format.parse(authDateStr);
- }
- Integer authImageType = paramsMap.getInteger("authImageType");
- String authImageLogo = paramsMap.getString("authImageLogo");
- String authImage = paramsMap.getString("authImage");
- Integer customFlag = paramsMap.getInteger("customFlag");
- String remarks = paramsMap.getString("remarks");
- List<String> bannerList = (List<String>) paramsMap.get("bannerList");
- String authParty = paramsMap.getString("authParty");
- Integer source = paramsMap.getInteger("source");
- String relationId = paramsMap.getString("relationId");
- String relationName = paramsMap.getString("relationName");
- if (null == source) {
- // 默认供应商保存
- source = 1;
- }
- /*
- 组装授权数据
- */
- CmBrandAuthPo auth = new CmBrandAuthPo();
- auth.setId(authId);
- auth.setAuthUserId(authUserId);
- auth.setAuthParty(authParty);
- auth.setProvinceId(provinceId);
- auth.setCityId(cityId);
- auth.setTownId(townId);
- auth.setAddress(address);
- auth.setCustomFlag(customFlag);
- auth.setRemarks(remarks);
- if (StringUtils.isEmpty(lngAndLat)) {
- return ResponseJson.error("参数异常,经纬度不能为空");
- }
- String[] split = lngAndLat.split(",");
- auth.setLng(new BigDecimal(split[0]));
- auth.setLat(new BigDecimal(split[1]));
- auth.setMobile(mobile);
- auth.setUserMobile(userMobile);
- auth.setLinkMan(linkMan);
- auth.setLinkMobile(linkMobile);
- auth.setFirstClubType(firstClubType);
- auth.setSecondClubType(secondClubType);
- auth.setMedicalLicenseImage(medicalLicenseImage);
- auth.setEmpNum(empNum);
- auth.setLogo(logo);
- auth.setAuthCode(authCode);
- auth.setAuthDate(authDate);
- auth.setAuthImageLogo(authImageLogo);
- auth.setAuthImage(authImage);
- auth.setAuthImageType(authImageType);
- auth.setCreateBy(createBy);
- auth.setCreateSource(1);
- auth.setRelationId(relationId);
- auth.setRelationName(relationName);
- return authService.saveAuth(auth, bannerList, false, source);
- }
- /**
- * 添加/编辑授权
- * 1.7.4版本:编辑时新加关联机构操作
- */
- @ApiOperation("添加/编辑授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
- "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
- "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
- "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
- "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
- "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
- "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
- @PostMapping("/saverelationg")
- @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
- public ResponseJson savesaverelationg(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- JSONObject paramsMap = JSONObject.parseObject(params);
- // Integer authUserId = paramsMap.getInteger("authUserId");
- // Integer createBy = paramsMap.getInteger("createBy");
- Integer authId = paramsMap.getInteger("authId");
- Integer provinceId = paramsMap.getInteger("provinceId");
- Integer cityId = paramsMap.getInteger("cityId");
- Integer townId = paramsMap.getInteger("townId");
- String address = paramsMap.getString("address");
- String lngAndLat = paramsMap.getString("lngAndLat");
- String mobile = paramsMap.getString("mobile");
- String userMobile = paramsMap.getString("userMobile");
- String linkMan = paramsMap.getString("linkMan");
- String linkMobile = paramsMap.getString("linkMobile");
- Integer firstClubType = paramsMap.getInteger("firstClubType");
- Integer secondClubType = paramsMap.getInteger("secondClubType");
- String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
- Integer empNum = paramsMap.getInteger("empNum");
- String logo = paramsMap.getString("logo");
- String authCode = paramsMap.getString("authCode");
- String authDateStr = paramsMap.getString("authDate");
- SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
- String relationId = paramsMap.getString("relationId");
- String relationName = paramsMap.getString("relationName");
- Date authDate = null;
- if (StringUtils.isNotEmpty(authDateStr)) {
- authDate = format.parse(authDateStr);
- }
- Integer authImageType = paramsMap.getInteger("authImageType");
- String authImageLogo = paramsMap.getString("authImageLogo");
- String authImage = paramsMap.getString("authImage");
- Integer customFlag = paramsMap.getInteger("customFlag");
- String remarks = paramsMap.getString("remarks");
- List<String> bannerList = (List<String>) paramsMap.get("bannerList");
- String authParty = paramsMap.getString("authParty");
- Integer source = paramsMap.getInteger("source");
- if (null == source) {
- // 默认供应商保存
- source = 1;
- }
- /*
- 组装授权数据
- */
- CmBrandAuthPo auth = new CmBrandAuthPo();
- auth.setId(authId);
- auth.setAuthUserId(authUserId);
- auth.setAuthParty(authParty);
- auth.setProvinceId(provinceId);
- auth.setCityId(cityId);
- auth.setTownId(townId);
- auth.setAddress(address);
- auth.setCustomFlag(customFlag);
- auth.setRemarks(remarks);
- if (StringUtils.isEmpty(lngAndLat)) {
- return ResponseJson.error("参数异常,经纬度不能为空");
- }
- String[] split = lngAndLat.split(",");
- auth.setLng(new BigDecimal(split[0]));
- auth.setLat(new BigDecimal(split[1]));
- auth.setMobile(mobile);
- auth.setUserMobile(userMobile);
- auth.setLinkMan(linkMan);
- auth.setLinkMobile(linkMobile);
- auth.setFirstClubType(firstClubType);
- auth.setSecondClubType(secondClubType);
- auth.setMedicalLicenseImage(medicalLicenseImage);
- auth.setEmpNum(empNum);
- auth.setLogo(logo);
- auth.setAuthCode(authCode);
- auth.setAuthDate(authDate);
- auth.setAuthImageLogo(authImageLogo);
- auth.setAuthImage(authImage);
- auth.setAuthImageType(authImageType);
- auth.setCreateBy(createBy);
- auth.setCreateSource(1);
- auth.setRelationId(relationId);
- auth.setRelationName(relationName);
- return authService.saveAuth(auth, bannerList, false, source);
- }
- /**
- * 审核品牌授权
- */
- @ApiOperation("审核品牌授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
- "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
- @PostMapping("/audit")
- public ResponseJson auditAuth(@CurrentUser SysUser sysUser, @RequestBody String params) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取审核人用户id
- Integer auditBy = sysUser.getId();
- if (null == auditBy) {
- return ResponseJson.error("审核人用户id不能为空", null);
- }
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- Integer auditStatus = paramsMap.getInteger("auditStatus");
- String invalidReason = paramsMap.getString("invalidReason");
- Integer source = paramsMap.getInteger("source");
- return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
- }
- @ApiOperation("excel导入")
- @ApiImplicitParam(name = "file", required = true, value = "机构excel表格")
- @PostMapping("/import/excel")
- public ResponseJson importDataByExcel(@CurrentUser SysUser sysUser, MultipartFile file) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- Integer createBy = sysUser.getId();
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- if (null == createBy) {
- return ResponseJson.error("参数异常,请输入创建人id");
- }
- if (null == file) {
- return ResponseJson.error("参数异常,请选择文件");
- }
- return authService.importDataByExcel(file, authUserId, createBy);
- }
- @ApiOperation("ldm门店图/备注导入")
- @GetMapping("/ldm/image/import")
- public ResponseJson importLdmImage(@CurrentUser SysUser sysUser) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.importLdmImage(authUserId);
- }
- @ApiOperation("更改查看标记")
- @PostMapping("/check/{id}")
- public ResponseJson checkAuth(@PathVariable("id") Integer authId) {
- return authService.checkAuth(authId);
- }
- @ApiOperation("勾选明星机构")
- @ApiImplicitParam(name = "params", required = true, value = "authId:机构id;starFlag:明星机构标识:1明星机构,0不是;starNum明星机构数值(用于排序,数值越大排名越前)")
- @PostMapping("/star")
- public ResponseJson starAuth(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- Integer starFlag = paramsMap.getInteger("starFlag");
- String starNum = paramsMap.getString("starNum");
- if (null == authId) {
- return ResponseJson.error("机构id不能为空");
- }
- if (null == starFlag) {
- return ResponseJson.error("明星机构标识不能为空");
- }
- return authService.starAuth(authId, starFlag, starNum);
- }
- /**
- * 获取机构关联的机构信息
- * 1.7.4版本:编辑时新加关联机构操作
- */
- @PostMapping("/product/relation/list")
- public ResponseJson<List<AuthFormVo>> getRelationgInfo(@CurrentUser SysUser sysUser, @RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- String snCode = paramsMap.getString("snCode");
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getRelationgInfo(snCode, authUserId);
- }
- /**
- * 获取可绑定机构机构信息
- * 1.7.4版本:编辑时新加关联机构操作
- */
- @GetMapping("/club/bind/list")
- public ResponseJson<List<AuthFormVo>> getClubBindAuth(@CurrentUser SysUser sysUser) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getClubBindAuth(authUserId);
- }
- //-----------------------------------------------------上传视频至抖音-----------------------------------------------------------------------------------
- /**
- * 用户扫码授权,获取code值
- *
- * @param response
- * @throws IOException
- */
- @GetMapping("/check/accesstoken")
- public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
- return authService.getDouYingCode(response);
- }
- /**
- * 清除抖音授权token缓存
- * @return
- */
- @GetMapping("/clean/douyin/redis")
- public ResponseJson cleanDYRedis(){
- redisService.remove("DYaccessToken");
- redisService.remove("DyrefreshToken");
- redisService.remove("DyopenId");
- return ResponseJson.success();
- }
- /**
- * 根据用户的code值获取AcessToken
- * ccode 用户授权登录code
- **/
- @GetMapping("/get/douying/acesstoken")
- public ResponseJson getDouYingAcessToken(String code) throws IOException {
- return authService.getDouYingAcessToken(code);
- }
- /**
- * h5的方式上传视频
- *
- * @return
- * @throws IOException
- */
- @PostMapping("/upload/video/to/douyin")
- public ResponseJson getclientToken(@RequestBody String params) throws IOException {
- JSONObject paramsMap = JSONObject.parseObject(params);
- String title = paramsMap.getString("title");
- String videoPath = paramsMap.getString("videoPath");
- Integer authId = paramsMap.getInteger("authId");
- return authService.getclientToken(title, videoPath, authId);
- }
- /**
- * 发布视频后通过webhook获取回调数据
- *
- * @param params
- * @return
- */
- @PostMapping("/webhook")
- @ResponseBody
- @WebHooks
- public Object webhook(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- System.out.println(paramsMap.getString("item_id"));
- String content = paramsMap.getString("content");
- JSONObject contentList = JSONObject.parseObject(content);
- System.out.println(content);
- String challenge = contentList.getString("challenge");
- System.out.println(challenge);
- String itemId = contentList.getString("item_id");
- System.out.println(itemId);
- String shareId = contentList.getString("share_id");
- //根据回调的shareId保存itemId
- if (StringUtils.isNotEmpty(shareId) && StringUtils.isNotEmpty(itemId)) {
- if (authService.getShareId(shareId)) {
- //根据shareId保存itemId
- authService.savaItemIdByShareId(shareId, itemId);
- }
- }
- System.out.println(shareId);
- Map<String, String> map = new HashMap<>();
- map.put("challenge", challenge);
- map.put("item_id", itemId);
- map.put("share_id", shareId);
- return map;
- }
- /**
- * 把抖音分享视频口令以短信推送给机构
- *
- * @return
- */
- @PostMapping("/sms/send/douyin")
- public ResponseJson sms(@RequestBody String params) {//String mobile,String content
- JSONObject jsonObject = JSONObject.parseObject(params);
- //根据authId获取手机号
- Integer authId = jsonObject.getInteger("authId");
- String mobile = authService.getMobileByAuthId(authId);
- //根据authId获取供应商名称
- String authUserName = authService.getAuthUserName(authId);
- String content = jsonObject.getString("content");
- // String authParty=jsonObject.getString("authParty");
- // 短信类型:1通知短信,2验证码短信,3营销短信
- String con = content.substring(0, content.indexOf("/") + 1);
- String cs = content.substring(content.indexOf("com") + 3);
- Integer type = 1;
- String kouLin = "[" + authUserName + "]您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:" + con + " https://v.douyin.com" + cs + ",您可复制该口令后去抖音平台打开";
- Boolean flag = SmsUtils.sendSms(type, mobile, kouLin);
- if (flag) {
- //短信发送成功后,保存口令
- authService.savaDyCommand(authId, content);
- return ResponseJson.success();
- } else {
- return ResponseJson.error("短信发送失败-----" + mobile);
- }
- }
- // /**
- // * 保存视频信息
- // * @return
- // */
- // @PostMapping("/save/video/info")
- // public ResponseJson saveVideoInfo(@RequestBody String params){
- // JSONObject jsonObject=JSONObject.parseObject(params);
- //// //验证用户是否可以发布视频
- //// //是否为机构用户
- // Integer authId=jsonObject.getInteger("authId");
- //// boolean flagAtuhId= authService.getauthUserId(authId);
- //// if(flagAtuhId){
- //// return ResponseJson.error("-1","由于您未认证机构,无法参与!");
- //// }
- //// //用户是否已经发不过视频
- // String userName=jsonObject.getString("userName");
- //// Boolean flaguserName=authService.getuserName(userName);
- //// if(!flaguserName){
- //// return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
- //// }
- //// //判断是否在活动时间内
- //// Date date=new Date();
- //// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //// String releaseTime = sf.format(date).replace("T", "");
- //// boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
- //// if(flagReleaseTime){
- //// return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
- //// }
- // String title=jsonObject.getString("title");
- // String ossName=jsonObject.getString("ossName");
- // String cover=jsonObject.getString("cover");
- // String ossUrl=jsonObject.getString("ossUrl");
- // ChallengeRoundVo cr=new ChallengeRoundVo();
- // cr.setUserName(userName);
- // cr.setCover(cover);
- // cr.setOssName(ossName);
- // cr.setOssUrl(ossUrl);
- // cr.setTitle(title);
- // cr.setAuthId(authId);
- // return authService.saveVideoInfo(cr);
- // }
- // @PostMapping("/get/published/video/list")
- // public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(@RequestBody String params){
- // JSONObject jsonObject=JSONObject.parseObject(params);
- // Integer status=jsonObject.getInteger("status");//1:未上传至抖音(前端使用) 否则不传(后端使用)
- // String clubUserName=jsonObject.getString("clubUserName");
- // Integer count=jsonObject.getInteger("count");
- // Integer cursor =jsonObject.getInteger("cursor");
- // if(count==null){
- // count=10;
- // }
- // if(cursor==null){
- // cursor=0;
- // }
- // return authService.getPublishedVideoList(clubUserName,status,cursor,count);
- // }
- //
- // /**
- // * 验证视频是否符合发布条件
- // * @param params
- // * @return
- // */
- // @PostMapping("/check/video/info")
- // public ResponseJson checkVideoInfo(@RequestBody String params){
- // JSONObject jsonObject=JSONObject.parseObject(params);
- // //验证用户是否可以发布视频
- // //是否为机构用户
- // Integer authId=jsonObject.getInteger("authId");
- // boolean flagAtuhId= authService.getauthUserId(authId);
- // if(flagAtuhId){
- // return ResponseJson.error("-1","由于您未认证机构,无法参与!");
- // }
- // //用户是否已经发不过视频
- // String userName=jsonObject.getString("userName");
- // Boolean flaguserName=authService.getuserName(userName);
- // if(!flaguserName){
- // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
- // }
- // //判断是否在活动时间内
- // Date date=new Date();
- // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- // String releaseTime = sf.format(date).replace("T", "");
- // boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
- // if(flagReleaseTime){
- // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
- // }
- // return ResponseJson.success();
- // }
- /**
- * 保存活动信息
- *
- * @param params
- * @return
- */
- @PostMapping("/save/activity/time")
- public ResponseJson saveActivityTime(@CurrentUser SysUser sysUser, @RequestBody String params) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- JSONObject jsonObject = JSONObject.parseObject(params);
- String startTime = jsonObject.getString("startTime");
- String endTime = jsonObject.getString("endTime");
- Integer status = jsonObject.getInteger("status");
- authService.saveActivityTime(startTime, endTime, status, authUserId);
- return ResponseJson.success();
- }
- /**
- * 获取活动信息
- *
- * @return
- */
- @GetMapping("/get/activity/time")
- public ResponseJson<ChallengeActivityVo> getActivityTime(@CurrentUser SysUser sysUser) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getActivityTime(authUserId);
- }
- /**
- * 获取已发布视频
- *
- * @param sysUser
- * @param status
- * @param cursor
- * @param count
- * @return
- */
- @GetMapping("/get/published/video/list")
- public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser, Integer status, String userName, String authParty, Integer cursor, Integer count, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,String startTIme,String endTime) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- if (count == null) {
- count = 10;
- }
- if (cursor == null) {
- cursor = 0;
- }
- return authService.getPublishedVideo(userName, authParty, status, cursor, count, authUserId, pageNum, pageSize,startTIme,endTime);
- }
- /**
- * 获取机构已发布视频的机构下拉列表
- *
- * @return
- */
- @GetMapping("/get/auth/party/list")
- public ResponseJson<List<ChallengeRoundVo>> getAuthPartylist(@CurrentUser SysUser sysUser) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getAuthPartylist(authUserId);
- }
- /**
- * 删除视频
- *
- * @param videoId
- * @return
- */
- @GetMapping("/del/video")
- public ResponseJson delVideo(Integer videoId) {
- //删除阿里云存储视频
- String ossName = authService.getOssNameAuthId(videoId);
- OSSUtils.deleteSingleFile(ossName);
- //删除视频信息
- authService.deleteVideoByAuthId(videoId);
- return ResponseJson.success();
- }
- /**
- * 下载视频
- *
- * @param fileId
- * @param response
- * @return
- */
- @GetMapping("/downLoad/chose/zip")
- public ResponseJson downLoadChoseZip(String fileId, HttpServletResponse response) {
- return authService.downLoadChoseZip(fileId, response);
- }
- /**
- * 根据id获取信息
- */
- @GetMapping("/get/info/by/id")
- public ResponseJson<ChallengeRoundVo> getInfoById(Integer videoId) {
- return authService.getInfoById(videoId);
- }
- @GetMapping("/getDyVidoInfo")
- public ResponseJson getDyVidoInfo(@CurrentUser SysUser sysUser){
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- return authService.getDyVidoInfo(authUserId);
- }
- //------------------------------------------抖音挑战赛1.7.7版本----------------------------------------------------------------------------------------------------------------
- /**
- * 查询机构信息(后端)
- * @param mobile
- * @return
- */
- @GetMapping("/get/auth/info")
- public ResponseJson<PageInfo<RossChallengeRoundVo>> getAuthInfo(String mobile,
- @CurrentUser SysUser sysUser,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authService.getAuthInfo(mobile,pageNum,pageSize,authUserId);
- }
- /**
- * 根据id删除机构信息
- * @param id
- * @return
- */
- @GetMapping("/del/auth/info")
- public ResponseJson delAuthInfoById(Integer id){
- //删除机构信息
- return authService.delAuthInfoById(id);
- }
- /**
- * 根据id删除视频信息
- * @param id
- * @return
- */
- @GetMapping("/del/video/info")
- public ResponseJson delVideoInfoById(Integer id){
- return authService.delVideoInfoById(id);
- }
- }
|