Skip to content

Commit

Permalink
订餐
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekoe committed Feb 18, 2019
1 parent db32e6c commit 62308a9
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 15 deletions.
23 changes: 19 additions & 4 deletions rest/src/main/java/com/rekoe/module/DingCanModule.java
Expand Up @@ -10,6 +10,8 @@
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
Expand Down Expand Up @@ -91,9 +93,14 @@ private void loadSeller() {
poiInfo.put("head_pic_url", "http://meal.rekoe.com/style/img/154901190572945.png");
}

private List<NutMap> loadFoods(long sellerId) {
private List<NutMap> loadFoods(long sellerId, String userProvince) {
List<NutMap> foodSpuTags = new ArrayList<NutMap>();
dao.each(FoodCategory.class, Cnd.where("seller_id", "=", sellerId).asc("id"), new Each<FoodCategory>() {
Sql sql = Sqls.create("select id from meal_seller $condition");
sql.setCallback(Sqls.callback.longs());
sql.setCondition(Cnd.where("province", "=", userProvince).and("deleted", "=", false));
dao.execute(sql);
List<Long> sids = sql.getList(Long.class);
dao.each(FoodCategory.class, sellerId == -1 ? Cnd.where("seller_id", "in", sids) : Cnd.where("seller_id", "=", sellerId).asc("id"), new Each<FoodCategory>() {
@Override
public void invoke(int index, FoodCategory category, int length) throws ExitLoop, ContinueLoop, LoopException {
NutMap foodSpuTag = NutMap.NEW();
Expand Down Expand Up @@ -255,15 +262,19 @@ public Result new_ratings(@Param("::") NutMap param) {

@At
@Ok("json")
public Result new_goods(@Param("id") long id) {
public Result new_goods(@Param("id") long id, @Param(value = "user_province", df = "北京市") String userProvince) {
NutMap tags = sellerFoodSpuTags.get(id);
if (tags == null) {
synchronized (lock) {
long iid = id;
if (id == -1) {
id = userProvince.hashCode();
}
tags = sellerFoodSpuTags.get(id);
if (tags == null) {
tags = NutMap.NEW();
tags.put("container_operation_source", special);
tags.put("food_spu_tags", loadFoods(id));
tags.put("food_spu_tags", loadFoods(iid, userProvince));
tags.put("code", 0);
tags.put("msg", "成功");
sellerFoodSpuTags.put(id, tags);
Expand All @@ -273,6 +284,10 @@ public Result new_goods(@Param("id") long id) {
return Result.success().addData("data", tags);
}

public static void main(String[] args) {
System.out.println("陕西省".hashCode());
}

@At
@Ok("json")
public Result new_seller(@Param("::") NutMap param) {
Expand Down
2 changes: 1 addition & 1 deletion rest/src/main/resources/static/index.html
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><title>OM-PLATFORM</title><link rel="shortcut icon" href=./static/icon/favicon.ico><meta name=apple-mobile-web-app-capable content=yes><link rel=stylesheet href=http://unpkg.zhimg.com/element-ui/lib/theme-chalk/index.css><script src=http://unpkg.zhimg.com/vue@2.5.2/dist/vue.js></script><script src=http://unpkg.zhimg.com/element-ui/lib/index.js></script><script src=https://cdn.bootcss.com/vue-router/2.3.0/vue-router.min.js></script><script src=https://cdn.bootcss.com/vuex/3.0.1/vuex.min.js></script><script src=https://cdn.bootcss.com/axios/0.17.1/axios.min.js></script><script src=//unpkg.zhimg.com/element-ui/lib/umd/locale/zh-CN.js></script><script src=http://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js></script><link rel=stylesheet href=./static/css/reset.css><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" name=viewport><link href=/static/css/app.360141a6db3f98e86394034a4b096d48.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.69f4330d7dfbcdf79b56.js></script><script type=text/javascript src=/static/js/vendor.046921ea18d121bcc641.js></script><script type=text/javascript src=/static/js/app.514f7b262189c6e656c1.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><title>OM-PLATFORM</title><link rel="shortcut icon" href=./static/icon/favicon.ico><meta name=apple-mobile-web-app-capable content=yes><link rel=stylesheet href=http://unpkg.zhimg.com/element-ui/lib/theme-chalk/index.css><script src=http://unpkg.zhimg.com/vue@2.5.2/dist/vue.js></script><script src=http://unpkg.zhimg.com/element-ui/lib/index.js></script><script src=https://cdn.bootcss.com/vue-router/2.3.0/vue-router.min.js></script><script src=https://cdn.bootcss.com/vuex/3.0.1/vuex.min.js></script><script src=https://cdn.bootcss.com/axios/0.17.1/axios.min.js></script><script src=//unpkg.zhimg.com/element-ui/lib/umd/locale/zh-CN.js></script><script src=http://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js></script><link rel=stylesheet href=./static/css/reset.css><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" name=viewport><link href=/static/css/app.360141a6db3f98e86394034a4b096d48.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.7d41dc005464a20dda04.js></script><script type=text/javascript src=/static/js/vendor.046921ea18d121bcc641.js></script><script type=text/javascript src=/static/js/app.e792d06cbdf7528ee766.js></script></body></html>

This file was deleted.

Binary file not shown.

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62308a9

Please sign in to comment.