Merge remote-tracking branch 'origin/master'

master
kanade 3 years ago
commit 98c1115223

@ -0,0 +1,38 @@
package com.zh.project0512.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zh.project0512.model.Task;
import com.zh.project0512.service.ITaskService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Tag(name = "定时任务")
@RestController
public class ScheduleController {
@Autowired
private ITaskService taskService;
@Scheduled(cron = "0 0 0 * * ?")
public void taskBegin() {
UpdateWrapper<Task> ew = new UpdateWrapper<>();
LocalDateTime now = LocalDateTime.now();
ew.eq("status",0).eq("date_format(start, '%Y-%m-%d')", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.set("status",1).set("updateAt",now);
taskService.update(ew);
}
@Scheduled(cron = "0 0 0 * * ?")
public void taskEnd() {
UpdateWrapper<Task> ew = new UpdateWrapper<>();
LocalDateTime now = LocalDateTime.now();
ew.eq("status",1).eq("date_format(end, '%Y-%m-%d')", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.set("status",2).set("updateAt",now);
taskService.update(ew);
}
}

@ -109,9 +109,4 @@ public class UtilsController {
System.out.println(stringOps.get("name"));
}
@Scheduled(fixedRate = 60000) //每60秒执行一次
// @Scheduled(cron = "0 0 0 * * ?")
public void updDailyRank() {
System.out.println("进行中...");
}
}

@ -1,20 +0,0 @@
package com.zh.project0512.controller.manage;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "抖音")
@RestController
@RequestMapping("/douyin")
public class DouyinController {
private String rootUrl = "https://open.douyin.com";
@PostMapping("/code")
public Result getCode(){
String url = rootUrl + "/platform/oauth/connect/";
// String content = HttpClientDownPage.sendGet(url);
return Result.success("content");
}
}

@ -1,40 +0,0 @@
package com.zh.project0512.controller.manage;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Tag(name = "快手")
@RestController
@RequestMapping("/ks")
public class KsController {
@Value("${ks.appid}")
private String appid;
@Value("${ks.secret}")
private String secret;
@Value("${ks.redirectUrl}")
private String redirectUrl;
private String rootUrl = "https://open.kuaishou.com";
@PostMapping("/code")
public Result getCode(){
String code = "e1609427a93aa4434335c4d3e9a1773dd79e135cc65b965a725ade4e8b856996063874c4";
String url = rootUrl + "/oauth2/access_token";
Map<String, String> param = new HashMap<>();
param.put("app_id", appid);
param.put("app_secret", secret);
param.put("code",code);
param.put("grant_type", "authorization_code");
String s = null;
System.out.println(s);
return Result.success(s);
}
}

@ -32,16 +32,5 @@ import javax.validation.constraints.NotNull;
@RestController
@RequestMapping("/userTask")
public class UserTaskController {
@Autowired
private IUserTaskService userTaskService;
@Autowired
private IUserService userService;
@Data
static class AddUTParam {
@Schema(title = "任务id")
@NotNull(message = "taskId不能为空")
@Min(value = 1, message = "taskId最小值为1")
private Integer taskId;
}
}

@ -1,8 +1,13 @@
package com.zh.project0512.controller.wxApp;
import com.zh.project0512.model.Video;
import com.zh.project0512.service.IVideoService;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
@ -10,11 +15,22 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wxApp/douyin")
public class DouyinUController {
private String rootUrl = "https://open.douyin.com";
@Autowired
private IVideoService videoService;
@PostMapping("/code")
public Result getCode(){
String url = rootUrl + "/platform/oauth/connect/";
// String content = HttpClientDownPage.sendGet(url);
return Result.success("content");
}
@Operation(summary = "模拟用户上传")
@PostMapping("/videoTest")
public Result videoTest(@RequestBody Video video){
videoService.save(video);
return Result.success("content");
}
}

@ -4,6 +4,7 @@ package com.zh.project0512.controller.wxApp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zh.project0512.annotation.tokenValid;
import com.zh.project0512.model.UserTask;
import com.zh.project0512.service.ITaskService;
import com.zh.project0512.service.IUserService;
import com.zh.project0512.service.IUserTaskService;
import com.zh.project0512.utils.JwtUtil;
@ -13,6 +14,7 @@ import io.jsonwebtoken.Claims;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -29,12 +31,15 @@ import javax.validation.constraints.NotNull;
* @author zh
* @since 2022-05-27
*/
@Tag(name = "用户任务")
@RestController
@RequestMapping("/wxApp/userTask")
public class UserTaskUController {
@Autowired
private IUserTaskService userTaskService;
@Autowired
private ITaskService taskService;
@Autowired
private IUserService userService;
@Data
static class AddUTParam {
@ -48,16 +53,19 @@ public class UserTaskUController {
@tokenValid
@PostMapping("/add")
public Result add(@Validated @RequestBody AddUTParam param, @RequestHeader("token") @Parameter(name = "登录token") String token) {
Claims claims = new JwtUtil().parseJWT(token);
Integer userId = userService.selByOpenid(claims.getId()).getId();
Integer userId = userService.selByOpenid(new JwtUtil().parseOpenid(token)).getId();
Integer taskId = param.getTaskId();
if(userId == null){
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"用户不存在");
}
QueryWrapper<UserTask> queryWrapper = new QueryWrapper<>();
if (null != userTaskService.getMap(new QueryWrapper<UserTask>().eq("userId", userId).eq("taskId", param.getTaskId()))) {
if(null == taskService.getById(taskId)){
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"任务不存在");
}
if (null != userTaskService.getMap(new QueryWrapper<UserTask>().eq("userId", userId).eq("taskId", taskId))) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"已接受该任务");
}
userTaskService.save(new UserTask().setUserId(userId).setTaskId(param.getTaskId()));
userTaskService.save(new UserTask().setUserId(userId).setTaskId(taskId));
return Result.success("添加完成");
}
}

@ -32,7 +32,12 @@
</collection>
</resultMap>
<select id="referenceDateList" resultMap="referenceDateMap">
select date_format(t1.creatAt, '%Y-%m-%d') dat,t1.*,t2.tagId, t3.title as tagTitle
<!-- select t1.*,t2.tagId,t3.title as tagTitle,t4.brandId,t5.name as brandName from reference as t1-->
<!-- right join referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId-->
<!-- right join referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId-->
<!-- WHERE t1.id ORDER BY updateAt DESC,creatAt DESC-->
select date_format(t1.creatAt, '%Y-%m-%d') dat,t1.*,t2.tagId, t3.title as tagTitle,t4.brandId,t5.name as brandName
from reference t1,referenceTag t2,tag t3
WHERE
t3.id = t2.tagId and t2.referenceId = t1.id

Loading…
Cancel
Save