Commit 8af81657 by 苗权威

9.4

parent c5c5851a
......@@ -35,6 +35,17 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
......
......@@ -132,6 +132,7 @@ public interface Constants {
String BASIC_PREFIX = "Basic ";
String BEARER = "Bearer ";
String CAPTCHA_SMS = "https://account-center-test.chewrobot.com/api/captcha/sms";
String REFRESH_TOKEN = "https://account-center-test.chewrobot.com/api/sdk/token";
String SDK_TOKEN = "https://account-center-test.chewrobot.com/api/sdk/token";
String GET_USER_INFO_BY_TOKEN ="https://account-center-test.chewrobot.com/api/sdk/user/info";
String FLOWER_INTERFACE = "http://aws-nx2.chewrobot.com:18082/api/flower/count";
......
......@@ -13,6 +13,7 @@ import ai.qiwu.com.xiaoduhome.common.temple.rank.RankUtil;
import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingDocument;
import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument;
import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandPojo;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
......@@ -37,6 +38,7 @@ import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import static ai.qiwu.com.xiaoduhome.common.temple.play.PlayUtils.getPlayDocument;
......@@ -61,7 +63,7 @@ public class TempleUtils {
FRAME_RECOMMAND.getItems().get(1).getItems().get(0).setText("小度小度,打开推荐");
FRAME_RECOMMAND.getItems().get(0).setText("推荐作品");
FRAME_CATEGORY = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
FRAME_CATEGORY.getItems().get(1).getItems().get(0).setText("小度小度,打开古风");
FRAME_CATEGORY.getItems().get(1).getItems().get(0).setText("小度小度,打开第二十一个");
FRAME_CATEGORY.getItems().get(0).setText("作品分类");
}
......@@ -118,26 +120,58 @@ public class TempleUtils {
// return RANKING_DOCUMENT;
// }
public static RankingDocument getRankingFirst() {
RankingDocument document = JSON.parseObject(getDPLTemple("static/json/rankFirst.json"), RankingDocument.class);
List<GameProjectTb> bots = ScheduleService.getRankingList();
List<RankBotInfo> datas = new ArrayList<>();
for (int i = 0; i < 3; i++) {
GameProjectTb bot = bots.get(i);
RankBotInfo data = new RankBotInfo(new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString(),
new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(), correctName(bot.getName()));
if (i == 0) data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/first.png");
else if (i == 1) data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/second.png");
else data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/third.png");
OnProductDetail detail = ScheduleService.getProductIdDetail().get(bot.getBotAccount());
Date createTime = detail.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String time = sdf.format(createTime);
data.setTime(new StringBuilder(Constants.PRODUCT_INTRO.CREATE_TIME).append(time).toString());
data.setWatches(new StringBuilder("点击数: ").append(bot.getWatch()).toString());
data.setAuth(new StringBuilder(Constants.PRODUCT_INTRO.AUTHOR).append(bot.getAuthorName()).toString());
StringBuilder labels = new StringBuilder(Constants.PRODUCT_INTRO.LABEL);
for (String label: detail.getLabels()) {
labels.append(Constants.PRODUCT_INTRO.SPACE).append(label);
}
data.setLabel(labels.toString());
data.setIntro(detail.getIntro());
datas.add(data);
}
document.getMainTemplate().getItems().get(2).setData(datas);
return document;
}
public static RankingDocument getRanking() {
return RankUtil.getRankDocument();
}
public static RecommandDocument getRecommand2(int num) {
public static RecommandDocument getRecommend(int num) {
RecommandDocument document = JSON.parseObject(getDPLTemple("static/json/recommand2.json"), RecommandDocument.class);
List<RecommandBotInfo> firstRowData = new ArrayList<>();
List<RecommandBotInfo> secondRowData = new ArrayList<>();
StringBuilder botIds = new StringBuilder();
int upBound = num+8 <= ScheduleService.getAllProductCount()? num+8: ScheduleService.getAllProductCount();
for (int i = num; i < num+8; i++) {
for (int i = num; i < upBound; i++) {
OnProductDetail detail = ScheduleService.getAllOnProduct().get(i);
botIds.append(detail.getBotAccount()).append(File.separator);
String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(detail.getBannerImgUrl()).toString();
String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(detail.getName()).toString();
if (i < num+4) {
RecommandBotInfo recommend = new RecommandBotInfo(imgSrc, imageId, correctName(detail.getName()));
recommend.setNum(i-num+1);
firstRowData.add(recommend);
}else {
RecommandBotInfo recommend = new RecommandBotInfo(imgSrc, imageId, correctName(detail.getName()));
recommend.setNum(i-num+1);
secondRowData.add(recommend);
}
}
......@@ -145,9 +179,11 @@ public class TempleUtils {
botIds.deleteCharAt(botIds.length()-1);
String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
document.setRecommendIdList(idToken);
document.setCount(String.valueOf(botIds.length()));
document.setCount(String.valueOf(upBound-num));
}
//document.getMainTemplate().getItems().get(0).getItems().get(2).getItems().get(0).setData(datas);
List<RecommandPojo> listContainer = document.getMainTemplate().getItems().get(2).getItems();
listContainer.get(0).setData(firstRowData);
listContainer.get(1).setData(secondRowData);
return document;
}
......
......@@ -11,6 +11,10 @@ public class RankBotInfo {
private String imageSrc;
private String imageId;
private String imageName;
private Integer num;
public RankBotInfo() {
}
public RankBotInfo(String imageSrc, String imageId, String imageName) {
this.imageSrc = imageSrc;
......
......@@ -34,21 +34,30 @@ public class RankUtil {
RankingMainTemplate mainTemplate = new RankingMainTemplate();
RANKING_DOCUMENT.setMainTemplate(mainTemplate);
List<RankBotInfo> datas = new ArrayList<>();
List<RankBotInfo> dataFirst = new ArrayList<>();
List<RankBotInfo> dataSec = new ArrayList<>();
StringBuilder botIds = new StringBuilder();
for (GameProjectTb bot: ScheduleService.getRankingList()) {
int i = 0;
for (GameProjectTb bot : ScheduleService.getRankingList()) {
botIds.append(bot.getBotAccount()).append(File.separator);
String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
datas.add(rankBotInfo);
if (i < 4) {
dataFirst.add(rankBotInfo);
}else if (i < 8){
dataSec.add(rankBotInfo);
}else {
break;
}
i++;
}
if (botIds.length() != 0) {
botIds.deleteCharAt(botIds.length()-1);
String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
RANKING_DOCUMENT.setRankBotIds(idToken);
}
buildMainItem(datas, mainTemplate.getItems());
buildMainItem(dataFirst,dataSec, mainTemplate.getItems());
return RANKING_DOCUMENT;
}
......@@ -59,49 +68,65 @@ public class RankUtil {
GameProjectTbRepository repository = BaseHolder.getBean("gameProjectTbRepository");
List<GameProjectTb> bots;
try {
bots = repository.postRankBot(num*15);
bots = repository.postRankBot(num*8);
} catch (Exception e) {
log.error("查询后续排行榜作品信息出错");
return null;
}
if (bots == null || bots.size() == 0) return null;
StringBuilder botIds = new StringBuilder();
List<RankBotInfo> datas = new ArrayList<>();
List<RankBotInfo> dataFirst = new ArrayList<>();
List<RankBotInfo> dataSec = new ArrayList<>();
int i = 0;
for (GameProjectTb bot: bots) {
botIds.append(bot.getBotAccount()).append(File.separator);
String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
datas.add(rankBotInfo);
if (i < 3) {
rankBotInfo.setNum();
dataFirst.add(rankBotInfo);
} else if (i == 4) {
dataFirst.add(rankBotInfo);
} else if (i < 8) {
dataSec.add(rankBotInfo);
} else {
break;
}
i++;
}
if (botIds.length() != 0) {
botIds.deleteCharAt(botIds.length()-1);
String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
document.setRankBotIds(idToken);
document.setCount(String.valueOf(bots.size()));
}
buildMainItem(datas, mainTemplate.getItems());
buildMainItem(dataFirst, dataSec, mainTemplate.getItems());
return document;
}
private static void buildMainItem(List<RankBotInfo> datas, List<RankingPojo> items) {
private static void buildMainItem(List<RankBotInfo> dataFirst, List<RankBotInfo> dataSec, List<RankingPojo> items) {
RankingPojo main = new RankingPojo();
main.setType("Container");
main.setType("ScrollView");
main.setHeight("100%");
main.setWidth("100%");
main.setComponentId("whole");
main.setMarginTop("65dp");
RankingPojo list = new RankingPojo();
list.setType("List");
list.setHeight("100%");
list.setWidth("100%");
list.setDirection("horizontal");
list.setComponentId("scrollToIndex");
list.setData(datas);
list.setMarginLeft("15dp");
list.setData(dataFirst);
list.setItems(RANK_CONTAINER_LIST);
main.setItems(Collections.singletonList(list));
RankingPojo list2 = new RankingPojo();
list2.setType("List");
list2.setWidth("100%");
list2.setDirection("horizontal");
list2.setMarginLeft("15dp");
list2.setData(dataSec);
list2.setItems(RANK_CONTAINER_LIST);
main.setItems(Arrays.asList(list, list2));
items.add(RANK_BACKGROUND_IMG);
items.add(RANK_HEAD);
......@@ -119,7 +144,7 @@ public class RankUtil {
RankingPojo footer = new RankingPojo();
footer.setType("Footer");
footer.setHints(Arrays.asList("向右滑","向左滑","打开第一个","返回"));
footer.setHints(Arrays.asList("打开第一个","下一页","上一页","返回"));
footerCon.setItems(Collections.singletonList(footer));
......@@ -151,28 +176,51 @@ public class RankUtil {
private static List<RankingPojo> buildImgTextContainer() {
RankingPojo container = new RankingPojo();
container.setType("Container");
container.setAlignItems("center");
container.setWidth("220dp");
container.setMarginBottom("35dp");
container.setMarginLeft("15dp");
RankingPojo image = new RankingPojo();
image.setType("Image");
image.setSrc("${data.imageSrc}");
image.setHeight("220dp");
image.setWidth("220dp");
image.setComponentId("${data.imageId}");
image.setHeight("170dp");
image.setWidth("170dp");
image.setMarginLeft("7dp");
image.setMarginTop("7dp");
image.setPosition("absolute");
image.setScaleType("fitXY");
image.setBorderRadius("10dp");
Event onClickEvent = new Event("SendEvent", "${data.imageId}");
image.setOnClick(Collections.singletonList(onClickEvent));
RankingPojo frame = new RankingPojo();
frame.setType("Frame");
frame.setWidth("40dp");
frame.setHeight("40dp");
frame.setBackgroundColor("rgba(0,0,0,0.9)");
frame.setBorderRadius("12dp");
RankingPojo textContainer = new RankingPojo();
textContainer.setWidth("100%");
textContainer.setHeight("100%");
textContainer.setAlignItems("center");
RankingPojo numText = new RankingPojo();
numText.setText("${data.num}");
numText.setFontSize("25dp");
textContainer.setItems(Collections.singletonList(numText));
frame.setItems(Collections.singletonList(textContainer));
RankingPojo text = new RankingPojo();
text.setType("Text");
text.setFontSize("30dp");
text.setMarginTop("10dp");
text.setFontSize("25dp");
text.setMarginTop("140dp");
text.setMarginLeft("7dp");
text.setText("${data.imageName}");
container.setItems(Arrays.asList(image, text));
container.setItems(Arrays.asList(image, frame, text));
return Collections.singletonList(container);
}
......
package ai.qiwu.com.xiaoduhome.common.temple.rank;
import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryPagePojo;
import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
......@@ -27,12 +24,13 @@ public class RankingPojo {
private String top;
private String left;
private String src;
private String headerImage;
private String headerTitle;
private Boolean hasBackIcon;
private String componentId;
@JsonProperty("margin-top")
private String marginTop;
@JsonProperty("margin-bottom")
private String marginBottom;
private String direction;
@JsonProperty("align-items")
private String alignItems;
......@@ -49,4 +47,15 @@ public class RankingPojo {
private String bottom;
private List<String> hints;
private List<RankBotInfo> data;
@JsonProperty("flex-direction")
private String flexDirection;
@JsonProperty("max-lines")
private Integer maxLines;
@JsonProperty("margin-right")
private String marginRight;
@JsonProperty("text-overflow")
private String textOverflow;
@JsonProperty("background-color")
private String backgroundColor;
}
......@@ -11,6 +11,7 @@ public class RecommandBotInfo {
private String imageSrc;
private String imageId;
private String imageName;
private Integer num;
public RecommandBotInfo(String imageSrc, String imageId, String imageName) {
this.imageSrc = imageSrc;
......
......@@ -31,6 +31,8 @@ public class RecommandPojo {
private String componentId;
@JsonProperty("margin-top")
private String marginTop;
@JsonProperty("margin-bottom")
private String marginBottom;
private String direction;
@JsonProperty("align-items")
private String alignItems;
......
......@@ -3,6 +3,7 @@ package ai.qiwu.com.xiaoduhome.controller;
import ai.qiwu.com.xiaoduhome.common.TokenHolder;
import ai.qiwu.com.xiaoduhome.common.Utils;
import ai.qiwu.com.xiaoduhome.pojo.TokenDuerosResponse;
import ai.qiwu.com.xiaoduhome.pojo.TokenResponse;
import ai.qiwu.com.xiaoduhome.pojo.User;
import ai.qiwu.com.xiaoduhome.service.LoadBySMS;
import lombok.extern.slf4j.Slf4j;
......@@ -145,34 +146,35 @@ public class Oauth2Controller {
public @ResponseBody TokenDuerosResponse returnTokenToDueros(@RequestParam String grant_type,
@RequestParam(required = false) String code, @RequestParam String client_id,
@RequestParam String client_secret, @RequestParam String redirect_uri,
@RequestParam(required = false) String refresh_token,
@RequestParam(required = false) String refreshToken) {
log.info("小度请求Token,client_id:{};client_secret:{};redirect_uri:{};code:{}",
client_id, client_secret, redirect_uri, code);
if (code == null) {
log.info("refreshToken:{},{}",refresh_token,refreshToken);
return null;
}
log.info("小度请求Token,client_id:{};client_secret:{};redirect_uri:{};code:{}",
client_id, client_secret, redirect_uri, code);
@RequestParam(required = false) String refresh_token) {
log.info("小度请求Token,client_id:{};client_secret:{};redirect_uri:{};code:{};refreshToken:{}",
client_id, client_secret, redirect_uri, code, refresh_token);
// 请求会出现发来的消息每个值重复一遍的情况,待解决?
client_id = client_id.substring(client_id.lastIndexOf(",")+1);
client_secret = client_secret.substring(client_secret.lastIndexOf(",")+1);
redirect_uri = redirect_uri.substring(redirect_uri.lastIndexOf(",")+1);
code = code.substring(code.lastIndexOf(",")+1);
boolean verifyResult = Utils.verifyTokenRequest(client_id, client_secret, redirect_uri);
if (!verifyResult) {
log.error("不合规的Token请求");
return null;
}
if (code == null && refresh_token != null) {
TokenResponse tokenResponse = LoadBySMS.getTokenByRefreshToken(refresh_token);
if (tokenResponse == null) return null;
TokenDuerosResponse response = new TokenDuerosResponse();
response.setAccess_token(tokenResponse.getAccessToken());
response.setRefresh_token(tokenResponse.getRefreshToken());
response.setExpires_in(tokenResponse.getExpire());
return response;
}
code = code.substring(code.lastIndexOf(",")+1);
ConcurrentHashMap<String, TokenHolder> cache = LoadBySMS.getCodeToken();
TokenHolder holder = cache.get(code);
TokenHolder holder = cache.remove(code);
String accessToken;
if (holder == null || (accessToken =holder.getAccessToken())==null) {
log.error("没有对应的令牌");
return null;
}
cache.remove(code);
TokenDuerosResponse response = new TokenDuerosResponse();
response.setAccess_token(accessToken);
response.setRefresh_token(holder.getRefreshToken());
......
package ai.qiwu.com.xiaoduhome.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
/**
* @author 苗权威
* @dateTime 19-9-4 下午2:13
*/
@Controller
@RequestMapping("/xiaoduhome/img")
public class UpLoadImgController {
@GetMapping("/up")
public String uploadImage() {
return "linPicture";
}
@PostMapping("/up")
public @ResponseBody
void loadImage(MultipartFile file, String storyName, String imageType) {
StringBuilder builder = new StringBuilder("/root/GameEditor/mqw/xiaoduhome/image/tmp/");
builder.append(storyName).append(".").append(imageType);
File imageFile = new File(builder.toString());
try {
if (!imageFile.getParentFile().exists()) {
imageFile.mkdirs();
}
file.transferTo(imageFile.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -5,12 +5,12 @@ import ai.qiwu.com.xiaoduhome.service.DplBotService;
import ai.qiwu.com.xiaoduhome.service.ResponseEncapsulation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Map;
import java.util.UUID;
/**
* @author 苗权威
......
package ai.qiwu.com.xiaoduhome.pojo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
......@@ -11,6 +12,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class CaptchaSmsResponse {
private String message;
private String payload;
......
......@@ -3,6 +3,8 @@ package ai.qiwu.com.xiaoduhome.pojo;
import com.baidu.dueros.data.response.directive.Directive;
import com.baidu.dueros.model.Response;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -13,7 +15,8 @@ import java.util.Map;
* @author 苗权威
* @dateTime 19-8-28 下午3:22
*/
@Data
@Getter
@Setter
public class OverTimeDetail {
private final List<Directive> directives = new ArrayList<>();
private final Map<String, String> attributes = new HashMap<>();
......
package ai.qiwu.com.xiaoduhome.pojo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
......@@ -11,6 +12,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class TokenResponse {
private String accessToken;
private String message;
......
......@@ -23,6 +23,6 @@ public interface GameProjectTbRepository extends JpaRepository<GameProjectTb, In
@Query(value = "select p.id,p.intro,p.name,p.watch,p.banner_img_url,p.apply_status,p.bot_account,p.user_nickname from game_project_tb as p,game_project_label_tb as l where l.name= :category and p.id = l.project_id and p.apply_status=1", nativeQuery = true)
List<GameProjectTb> categoryProject(@Param("category") String category);
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 order by watch desc limit ?1,15", nativeQuery = true)
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 order by watch desc limit ?1,8", nativeQuery = true)
List<GameProjectTb> postRankBot(Integer begin);
}
package ai.qiwu.com.xiaoduhome.service;
import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.TokenHolder;
......@@ -184,6 +185,21 @@ public class LoadBySMS {
return CODE_TOKEN;
}
public static TokenResponse getTokenByRefreshToken(String refreshToken) {
HashMap<String, String> headers = new HashMap<>();
headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", refreshToken);
String smsStr = null;
try {
smsStr = OkHttp3Utils.doPost(XIAOWU_API.REFRESH_TOKEN, new HashMap<>(), headers);
} catch (Exception e) {
log.error("通过RefreshToken请求Token出错:{}",e.toString());
}
if (smsStr == null) return null;
return JSON.parseObject(smsStr, TokenResponse.class);
}
// /**
// * 获取accesstoken-phonenumber的缓存map
// * @return
......
......@@ -2,12 +2,12 @@
"type": "Container",
"flex-direction": "row",
"margin-bottom": "15dp",
"margin-top": "15dp",
"margin-top": "30dp",
"items": [
{
"type": "Text",
"text": "排行榜",
"font-size": "38dp",
"font-size": "34dp",
"margin-left": "30dp"
},
{
......@@ -18,11 +18,11 @@
"border-bottom-right-radius": "15dp",
"padding-vertical": "8dp",
"padding-horizontal": "15dp",
"background-color": "rgb(105,105,105)",
"background-color": "rgba(0,0,0,0.2)",
"items": [
{
"type": "Text",
"font-size": "28dp",
"font-size": "24dp",
"color": "rgb(255,255,255)"
}
]
......
......@@ -96,8 +96,8 @@
},
{
"type": "Text",
"font-size": "28dp",
"margin-top": "157dp",
"font-size": "24dp",
"margin-top": "159dp",
"margin-left": "7dp",
"text": "${data.imageName}"
}
......
{
"type": "DPL",
"version": "1.0",
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Image",
"position": "absolute",
"top": "0dp",
"left": "0dp",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg",
"height": "100%",
"width": "100%"
},
{
"type": "Header",
"headerTitle": "排行榜",
"hasBackIcon": false
},
{
"type": "Container",
"height": "100%",
"width": "100%",
"items": [
{
"type": "List",
"width": "100%",
"margin-left": "15dp",
"direction": "horizontal",
"items": [
{
"type": "Container",
"width":"220dp",
"margin-bottom": "35dp",
"margin-left": "15dp",
"items": [
{
"type": "Image",
"width": "170dp",
"height": "170dp",
"margin-left": "7dp",
"margin-top": "7dp",
"position": "absolute",
"componentId": "${data.imageId}",
"scale-type": "fitXY",
"border-radius": "10dp",
"src": "${data.imageSrc}",
"onClick": [
{
"type": "SendEvent",
"componentId": "${data.imageId}"
}
]
},
{
"type": "Frame",
"width": "40dp",
"height": "40dp",
"background-color": "rgba(0,0,0,0.9)",
"border-radius": "12dp",
"items": [
{
"type": "Container",
"width": "100%",
"height": "100%",
"align-items":"center",
"items": [
{
"type": "Text",
"text": "${data.num}",
"font-size": "25dp"
}
]
}
]
},
{
"type": "Text",
"font-size": "25dp",
"margin-top": "140dp",
"margin-left": "7dp",
"text": "${data.imageName}"
}
]
}
]
},
{
"type": "List",
"width": "100%",
"margin-left": "15dp",
"direction": "horizontal",
"items": [
{
"type": "Container",
"width":"220dp",
"margin-bottom": "35dp",
"margin-left": "15dp",
"items": [
{
"type": "Image",
"width": "170dp",
"height": "170dp",
"margin-left": "7dp",
"margin-top": "7dp",
"position": "absolute",
"componentId": "${data.imageId}",
"scale-type": "fitXY",
"border-radius": "10dp",
"src": "${data.imageSrc}",
"onClick": [
{
"type": "SendEvent",
"componentId": "${data.imageId}"
}
]
},
{
"type": "Frame",
"width": "40dp",
"height": "40dp",
"background-color": "rgba(0,0,0,0.9)",
"border-radius": "12dp",
"items": [
{
"type": "Container",
"width": "100%",
"height": "100%",
"align-items":"center",
"items": [
{
"type": "Text",
"text": "${data.num}",
"font-size": "25dp"
}
]
}
]
},
{
"type": "Text",
"font-size": "25dp",
"margin-top": "140dp",
"margin-left": "7dp",
"text": "${data.imageName}"
}
]
}
]
}
]
},
{
"type": "Container",
"position": "absolute",
"width": "100%",
"left": "0",
"bottom": "0",
"items": [
{
"type": "Footer",
"hints": [
"打开第一个","下一页","上一页","返回"
]
}
]
}
]
}
}
\ No newline at end of file
{
"type": "DPL",
"version": "1.0",
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Image",
"position": "absolute",
"top": "0dp",
"left": "0dp",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg",
"height": "100%",
"width": "100%"
},
{
"type": "Header",
"headerTitle": "排行榜",
"hasBackIcon": false
},
{
"type": "List",
"width": "100%",
"height": "100%",
"direction": "vertical",
"items": [
{
"type": "Container",
"flex-direction": "row",
"items": [
{
"type": "Image",
"width": "230dp",
"height": "230dp",
"src": "${data.imageSrc}",
"position": "absolute",
"border-radius": "15dp",
"onClick": [
{
"type": "SendEvent",
"componentId": "${data.imageId}"
}
]
},
{
"type": "Image",
"src": "${data.logo}",
"width": "30dp",
"height": "30dp",
"border-radius": "5dp"
},
{
"type": "Container",
"margin-left": "250dp",
"flex-direction": "column",
"items": [
{
"type": "Text",
"margin-top": "10dp",
"text": "${data.imageName}",
"font-size": "38dp",
"margin-left": "5%"
},
{
"type": "Text",
"text": "${data.watches}",
"margin-top": "10dp",
"font-size": "25dp",
"margin-left": "5%"
},
{
"type": "Container",
"margin-top": "10dp",
"flex-direction":"row",
"items":[
{
"type": "Text",
"text": "${data.time}",
"font-size": "22dp",
"margin-left": "5%"
},
{
"type": "Text",
"text": "${data.auth}",
"font-size": "22dp",
"margin-left": "10%"
}
]
},
{
"type": "Container",
"margin-top": "6dp",
"flex-direction":"row",
"items":[
{
"type": "Text",
"max-lines": 1,
"text": "${data.label}",
"font-size": "22dp",
"margin-left": "5%"
}
]
},
{
"type": "Container",
"margin-top": "9dp",
"margin-right": "26dp",
"items": [
{
"type": "Text",
"font-size": "25dp",
"line-height": "20dp",
"text": "${data.intro}",
"margin-top": "30dp",
"max-lines": 3,
"text-overflow": "ellipsis",
"margin-left": "5%"
}
]
}
]
}
]
}
]
}
]
}
}
\ No newline at end of file
......@@ -27,19 +27,19 @@
"items": [
{
"type": "List",
"height": "50%",
"width": "100%",
"margin-left": "15dp",
"direction": "horizontal",
"items": [
{
"type": "Container",
"width":"220dp",
"margin-left": "15dp",
"items": [
{
"type": "Image",
"width": "220dp",
"height": "220dp",
"width": "170dp",
"height": "170dp",
"margin-left": "7dp",
"margin-top": "7dp",
"position": "absolute",
......@@ -56,10 +56,10 @@
},
{
"type": "Frame",
"width": "45dp",
"height": "45dp",
"background-color": "rgb(0,0,0)",
"border-radius": "10dp",
"width": "40dp",
"height": "40dp",
"background-color": "rgba(0,0,0,0.7)",
"border-radius": "12dp",
"items": [
{
"type": "Container",
......@@ -70,9 +70,7 @@
{
"type": "Text",
"text": "${data.num}",
"font-size": "28dp",
"margin-top": "157dp",
"margin-left": "7dp"
"font-size": "28dp"
}
]
}
......@@ -80,8 +78,9 @@
},
{
"type": "Text",
"font-size": "30dp",
"margin-top": "10dp",
"font-size": "25dp",
"margin-top": "140dp",
"margin-left": "7dp",
"text": "${data.imageName}"
}
]
......@@ -90,19 +89,19 @@
},
{
"type": "List",
"height": "50%",
"width": "100%",
"margin-left": "15dp",
"direction": "horizontal",
"items": [
{
"type": "Container",
"width":"220dp",
"margin-left": "15dp",
"items": [
{
"type": "Image",
"width": "220dp",
"height": "220dp",
"width": "170dp",
"height": "170dp",
"margin-left": "7dp",
"margin-top": "7dp",
"position": "absolute",
......@@ -119,10 +118,10 @@
},
{
"type": "Frame",
"width": "45dp",
"height": "45dp",
"background-color": "rgb(0,0,0)",
"border-radius": "10dp",
"width": "40dp",
"height": "40dp",
"background-color": "rgba(0,0,0,0.7)",
"border-radius": "12dp",
"items": [
{
"type": "Container",
......@@ -133,9 +132,7 @@
{
"type": "Text",
"text": "${data.num}",
"font-size": "28dp",
"margin-top": "157dp",
"margin-left": "7dp"
"font-size": "28dp"
}
]
}
......@@ -143,8 +140,9 @@
},
{
"type": "Text",
"font-size": "30dp",
"margin-top": "10dp",
"font-size": "25dp",
"margin-top": "140dp",
"margin-left": "7dp",
"text": "${data.imageName}"
}
]
......@@ -163,7 +161,7 @@
{
"type": "Footer",
"hints": [
"打开第一个","下一页","返回"
"打开第一个","下一页","上一页","返回"
]
}
]
......
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>图片上传</title>
<script type="text/javascript">
function uploadImage() {
var imageExtend = document.getElementById("imageExtend").value;
var storyName = document.getElementById("storyName").value;
var fileObj = document.querySelector("#smallFile").files[0];
var formData = new FormData();
formData.append("file", fileObj);
formData.append("storyName", storyName);
formData.append("imageType", imageExtend);
var ajaxObj = new XMLHttpRequest();
ajaxObj.open('POST', '/xiaoduhome/img/up', true);
ajaxObj.send(formData);
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4) {
var status = ajaxObj.status;
if (status >= 200 && status < 300 || status === 304) {
alert("上传图片成功");
} else {
alert("上传图片出错");
}
}
}
}
</script>
</head>
<body>
<p class="introl">图片,填写图片名,选择图片类型.注:图片名要唯一</p>
<input type="text" id="storyName" th:placeholder="请填写作品名-拼音" th:value="${storyName}">
<select id="imageExtend" th:value="${imageExtend}">
<option value="jpg">jpg</option>
<option value="png">png</option>
</select><br>
<input type="file" id="smallFile" accept="image/gif,image/jpeg,image/jpg,image/png"><br>
<input type="button" onclick="uploadImage()" value="上传图"/>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment