package com.happy.action;

import com.alibaba.fastjson.JSONObject;
import com.happy.Until.GetHttpParam;
import com.happy.Until.ResUtil;
import com.happy.common.controller.BaseController;
import com.happy.dto.HouseNumberDto;
import com.happy.service.HouseNumberService;
import com.opensymphony.xwork2.ModelDriven;
import lombok.SneakyThrows;
import org.apache.struts2.ServletActionContext;

import javax.annotation.Resource;

public class HouseNumberAction extends BaseController implements ModelDriven<HouseNumberDto> {
    private final HouseNumberDto houseNumberDto = new HouseNumberDto();

    @Override
    public HouseNumberDto getModel() {
        return houseNumberDto;
    }

    @Resource(name = "HouseNumberService")
    private HouseNumberService houseNumberService;


    /**
     * 置脏/净
     */
    @SneakyThrows
    public void modifyHouseStatus() {
        String postDataStr = GetHttpParam.getRequestPostData(request);
        HouseNumberDto postDataObj = JSONObject.parseObject(postDataStr, HouseNumberDto.class);
        houseNumberService.modifyHouseStatus(postDataObj);
        ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
            put("message", "请求成功");
            put("code", 200);
        }}.toString());
    }
}
