功能调整
parent
280df039e4
commit
8752ee98e7
@ -0,0 +1,35 @@
|
||||
package com.tz.platform.competitiion.api;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.competitiion.api.biz.NoteBiz;
|
||||
import com.tz.platform.competitiion.api.dto.NoteDTO;
|
||||
import com.tz.platform.competitiion.api.dto.NoteDateDTO;
|
||||
import com.tz.platform.competitiion.api.vo.NoteVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/competition/note")
|
||||
public class MarketNoteController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private NoteBiz noteBiz;
|
||||
|
||||
@PostMapping("add")
|
||||
public Result<String> add(@RequestBody NoteVO vo){
|
||||
return noteBiz.save(vo,getUserNo());
|
||||
}
|
||||
|
||||
@GetMapping("listDate")
|
||||
public Result<NoteDateDTO> listDate(){
|
||||
return noteBiz.listDate(getUserNo());
|
||||
}
|
||||
|
||||
@GetMapping("getByDate")
|
||||
public Result<NoteDTO> getByDate(@RequestParam("date") String date){
|
||||
return noteBiz.getByDate(date,getUserNo());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.tz.platform.competitiion.api.biz;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.common.core.tools.BeanUtils;
|
||||
import com.tz.platform.common.core.tools.DateUtil;
|
||||
import com.tz.platform.competitiion.api.dto.NoteDTO;
|
||||
import com.tz.platform.competitiion.api.dto.NoteDateDTO;
|
||||
import com.tz.platform.competitiion.api.vo.NoteVO;
|
||||
import com.tz.platform.entity.MarketNote;
|
||||
import com.tz.platform.repository.MarketNoteDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class NoteBiz {
|
||||
@Autowired
|
||||
private MarketNoteDao marketNoteDao;
|
||||
|
||||
public Result<String> save(NoteVO vo,Long userNo){
|
||||
if(userNo == null){
|
||||
return Result.error("无权限");
|
||||
}
|
||||
MarketNote note = BeanUtils.copyProperties(vo,MarketNote.class);
|
||||
if(StringUtils.isEmpty(vo.getId())){
|
||||
Date now = null;
|
||||
if(vo.getNoteDate()!=null){
|
||||
now = vo.getNoteDate();
|
||||
}else{
|
||||
now = new Date();
|
||||
}
|
||||
note.setNoteDate(now);
|
||||
note.setId(userNo+"_"+ DateUtil.format(now,"yyyy-MM-dd"));
|
||||
note.setUserId(userNo);
|
||||
}
|
||||
note = marketNoteDao.save(note);
|
||||
return Result.success(note.getId());
|
||||
}
|
||||
|
||||
public Result<NoteDTO> getByDate(String date,Long userNo){
|
||||
String id = userNo+"_"+date;
|
||||
MarketNote note = marketNoteDao.getById(id);
|
||||
if(note == null){
|
||||
return Result.error("无数据");
|
||||
}
|
||||
NoteDTO dto = BeanUtils.copyProperties(note,NoteDTO.class);
|
||||
return Result.success(dto);
|
||||
}
|
||||
|
||||
public Result<NoteDateDTO> listDate(Long userNo){
|
||||
if(userNo == null){
|
||||
return Result.error("无权限");
|
||||
}
|
||||
List<MarketNote> noteList = marketNoteDao.findAllByUserId(userNo);
|
||||
NoteDateDTO dto = new NoteDateDTO();
|
||||
dto.setNoteDate(new ArrayList<>());
|
||||
noteList.forEach(marketNote -> {
|
||||
dto.getNoteDate().add(marketNote.getId().substring(marketNote.getId().lastIndexOf("_")+1));
|
||||
});
|
||||
return Result.success(dto);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.tz.platform.competitiion.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class NoteDTO implements Serializable {
|
||||
private String id;
|
||||
private Date noteDate;
|
||||
private String market;
|
||||
private String stock;
|
||||
private String plain;
|
||||
private String mark;
|
||||
private String position;
|
||||
private Long userId;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.tz.platform.competitiion.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NoteDateDTO implements Serializable {
|
||||
private List<String> noteDate;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.tz.platform.competitiion.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class NoteVO {
|
||||
private String id;
|
||||
private Date noteDate;
|
||||
private String market;
|
||||
private String stock;
|
||||
private String plain;
|
||||
private String mark;
|
||||
private String position;
|
||||
private Long userId;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.tz.platform.repository;
|
||||
|
||||
import com.tz.platform.entity.MarketNote;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface MarketNoteDao extends JpaRepository<MarketNote,String> {
|
||||
List<MarketNote> findAllByUserId(Long userId);
|
||||
MarketNote getById(String id);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.tz.platform.feign.user;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
||||
@FeignClient(value = "tz-user-service")
|
||||
public interface IFeignZhiyun {
|
||||
@PostMapping(value = "/feign/user/synZhiyun")
|
||||
void synZhiyun();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.tz.platform.user.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ZhiyunTokenBO {
|
||||
private String tk;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.tz.platform.user.feign;
|
||||
|
||||
import com.tz.platform.feign.user.IFeignZhiyun;
|
||||
import com.tz.platform.zhiyun.biz.ZhiyunAccountBiz;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class FeignZhiyunController implements IFeignZhiyun {
|
||||
|
||||
@Autowired
|
||||
private ZhiyunAccountBiz zhiyunAccountBiz;
|
||||
|
||||
|
||||
@Override
|
||||
public void synZhiyun() {
|
||||
zhiyunAccountBiz.synJob();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue