| | |
| | | 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;
|
| | |
|
| | |
| | | public void changeSex(AcceptData acceptData, Integer sex, PrintWriter out) {
|
| | | try {
|
| | | // 获取设备定义性别
|
| | | int deviceSex = deviceSexService.changeDeviceSex(sex, acceptData.getDevice());
|
| | | deviceSexService.save(acceptData.getDevice(), sex);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("sex", deviceSex);
|
| | | data.put("sex", sex);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("切换失败"));
|
| | |
| | | // 获取设备定义性别
|
| | | int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice());
|
| | | List<HomeNavbar> listNavbar = homeNavbarUserService.listEffectiveNavbar(uid, acceptData.getDevice(), deviceSex);
|
| | | if (listNavbar == null) {
|
| | | listNavbar = new ArrayList<HomeNavbar>();
|
| | | |
| | | 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("sex", deviceSex);
|
| | | data.put("count", listNavbar.size());
|
| | | data.put("listNavbar", JsonUtil.getApiCommonGson().toJson(listNavbar));
|
| | | data.put("count", list.size());
|
| | | data.put("listNavbar", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | |
|
| | | // 设置为通用
|
| | | deviceSexService.changeDeviceSex(0, acceptData.getDevice());
|
| | | deviceSexService.save(acceptData.getDevice(), 0);
|
| | |
|
| | | } catch (HomeNavbarUserException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 设置为通用
|
| | | deviceSexService.changeDeviceSex(0, acceptData.getDevice());
|
| | | deviceSexService.save(acceptData.getDevice(), 0);
|
| | |
|
| | | } catch (HomeNavbarUserException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|