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> 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版本 * 新加两个查询条件 *

* 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> 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> 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 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 params) { Integer authId = params.get("authId"); return authService.deleteAuth(authId); } /** * 授权机构回显数据 */ @ApiOperation("授权机构回显数据") @ApiImplicitParam(name = "authId", required = true, value = "机构用户id") @GetMapping("/form/data") public ResponseJson 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 bannerList = (List) 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 bannerList = (List) 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> 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> 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 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> 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 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> 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> 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 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> 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); } }