| | |
| | | import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar.NavbarTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.HomeNavbarUser;
|
| | | import com.yeshi.fanli.exception.homemodule.HomeNavbarUserException;
|
| | | import com.yeshi.fanli.service.inter.homemodule.DeviceSexService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarUserService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private HomeNavbarUserService homeNavbarUserService;
|
| | | |
| | | @Resource
|
| | | private DeviceSexService deviceSexService;
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | | * 获取导航栏内容
|
| | | * |
| | | * 改变性别
|
| | | * @param acceptData
|
| | | * @param sex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "changeSex", method = RequestMethod.POST)
|
| | | public void changeSex(AcceptData acceptData, Integer sex, PrintWriter out) {
|
| | | try {
|
| | | // 获取设备定义性别
|
| | | deviceSexService.save(acceptData.getDevice(), sex);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("sex", sex);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("切换失败"));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取导航栏内容
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param sex 0通用 1男 2女
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getHomeItems", method = RequestMethod.POST)
|
| | | public void getHomeItems(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | List<HomeNavbar> listNavbar = homeNavbarUserService.listEffectiveNavbar(uid, acceptData.getDevice());
|
| | | if (listNavbar == null) {
|
| | | listNavbar = new ArrayList<HomeNavbar>();
|
| | | // 获取设备定义性别
|
| | | int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice());
|
| | | List<HomeNavbar> listNavbar = homeNavbarUserService.listEffectiveNavbar(uid, acceptData.getDevice(), deviceSex);
|
| | | |
| | | List<HomeNavbar> list = new ArrayList<HomeNavbar>();
|
| | | if (listNavbar != null) {
|
| | | list.addAll(listNavbar);
|
| | | } |
| | | |
| | | if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | for (int i = 0; i < list.size(); i ++) {
|
| | | NavbarTypeEnum type = list.get(i).getType();
|
| | | if (type == NavbarTypeEnum.commonTemplate) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", listNavbar.size());
|
| | | data.put("listNavbar", JsonUtil.getApiCommonGson().toJson(listNavbar));
|
| | | data.put("sex", deviceSex);
|
| | | data.put("count", list.size());
|
| | | data.put("listNavbar", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | if (homeNavbar.getIsDefault()) {
|
| | | listExist.add(homeNavbar);
|
| | |
|
| | | if (homeNavbar.getIsFixed()) {
|
| | | nonCount++;
|
| | | }
|
| | |
|
| | | |
| | | listExist.add(homeNavbar);
|
| | | listItems.remove(homeNavbar);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | homeNavbarUserService.addNavbarUser(uid, acceptData.getDevice(), list);
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | |
| | | // 设置为通用
|
| | | deviceSexService.save(acceptData.getDevice(), 0);
|
| | | |
| | | } catch (HomeNavbarUserException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | |
| | | int nonCount = 0;
|
| | | List<HomeNavbar> listExist = new ArrayList<HomeNavbar>();
|
| | | List<HomeNavbar> listItems = new ArrayList<HomeNavbar>();
|
| | |
|
| | | |
| | | |
| | | List<HomeNavbar> listNavbar = homeNavbarUserService.restoreSystemDefault(uid, acceptData.getDevice());
|
| | | if (listNavbar != null && listNavbar.size() > 0) {
|
| | | listItems.addAll(listNavbar);
|
| | |
| | | if (!homeNavbar.getIsDefault()) {
|
| | | break;
|
| | | } else {
|
| | | // 固定个数
|
| | | if (homeNavbar.getIsFixed()) {
|
| | | nonCount++;
|
| | | }
|
| | | // 默认项
|
| | | listExist.add(homeNavbar);
|
| | |
|
| | | listItems.remove(homeNavbar);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | data.put("listExist", JsonUtil.getApiCommonGson().toJson(listExist));
|
| | | data.put("listItems", JsonUtil.getApiCommonGson().toJson(listItems));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | // 设置为通用
|
| | | deviceSexService.save(acceptData.getDevice(), 0);
|
| | | |
| | | } catch (HomeNavbarUserException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|