关于重构同事祖传旧代码一事小记_实体类

关于重构同事祖传旧代码一事小记_xcode_02

开始我只能将其抽离到一个扩展类和做到实体类中 近似DDD的那种概念

现在已经将控制层的业务逻辑处理放到了service

service的一些操作放到了实体类

package com.wx.web.action.web;

import com.wx.web.annotation.Decrypt;
import com.wx.web.annotation.Encrypt;
import com.wx.web.service.zssb.ZssbService;
import com.wx.web.vo.BaseVO;
import com.wx.web.vo.zcbd.OneWgrsbVO;
import com.wx.web.vo.zcbd.WgrsbVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Locale;
import java.util.Map;

@Controller
@RequestMapping("/web/zssb")
@Slf4j
public class ZssbCtrl {

@Autowired
private ZssbService zssbService;

@Autowired
LocaleResolver localeResolver;

/**
* 退出登录
*
* @param dz
* @param session
* @return
*/
@RequestMapping("exit")
public String exit(String dz, HttpSession session) {
zssbService.exitAndSetSession(session);
return "redirect:/web/zcbd/login";
}

/**
* 帮助
*
* @return
*/
@RequestMapping("helppage")
public String helppage() {
return "/web/zcbd/helppage";
}

/**
* 移民咨询
*
* @return
*/
@RequestMapping("information")
public String information() {
return "/web/zcbd/information";
}

/**
* 是否继续申报
*
* @param session
* @return
*/
@RequestMapping("tjtzr")
public String tjtzr(String sbid, String yes, Model model, HttpSession session) {
String returns = zssbService.tjtzr(sbid, model, session);
return returns;
}

/**
* 撤销申报
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("chexiao")
public WgrsbVO chexiao(String sbid, String yes, Model model, HttpSession session) {
return zssbService.quxiaoshenbao(sbid, model, session);
}

/**
* 是否继续申报
*
* @param session
* @return
*/
@RequestMapping("continue")
public String continuesb(String yes, Model model, HttpSession session) {
return zssbService.jixushenbao(yes, model, session);
}

/**
* 跳转主页
*
* @param dz
* @param model
* @return
*/
@RequestMapping("main")
public String toReg(WgrsbVO vo, String xs, String locale, String roads, String pois, String sblx, String zwjzdz, String ssqx, String adcode, String qxcode, String lm,
String township, String mph, String dz, String jwd, String maodian, String dqjwd,
String zn, String jzh, Model model, String yes, HttpSession session, HttpServletRequest request) {
return zssbService.toRegPage(vo, xs, locale, roads, pois, sblx, zwjzdz, ssqx, adcode, qxcode, lm,
township, mph, dz, jwd, maodian, dqjwd, zn, jzh, model, yes, session, request);
}

/**
* 获得护照
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/getzjz")
public WgrsbVO getZjz(HttpServletRequest request, WgrsbVO vo, HttpSession session) {
Locale local = localeResolver.resolveLocale(request);
return zssbService.huodehuzhao(local, vo, session);
}

/**
* 获得证件照
* //FIXME ?? 看不懂为什么返回new Vo()
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/getzmz")
public BaseVO getzmz(WgrsbVO vo, HttpSession session) {
zssbService.huodeZhengjianZhaoKong(vo, session);
return new BaseVO();
}

/**
* 获得证件照
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/saveSb")
public BaseVO saveSb(HttpServletRequest request, WgrsbVO vo, HttpSession session) {
Locale local = localeResolver.resolveLocale(request);
return zssbService.huodeZhengjianZhao(local, vo, session);
}

/**
* 查询一条信息
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/getOneSb")
public WgrsbVO getOneSb(WgrsbVO vo, HttpSession session) {
return zssbService.chaxunXinxi(vo, session);
}

/**
* 查询一条信息
*
* @param session
* @return
*/
@ResponseBody
@Decrypt
@Encrypt
@RequestMapping("/getImgAll")
public OneWgrsbVO getimgall(WgrsbVO vo, HttpSession session) {
return zssbService.searchMsgAll(vo, session);
}

/**
* 查询一条信息
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/gethzrxlj")
public Map gethzrxlj(Model model, WgrsbVO vo, HttpSession session) {
return zssbService.chaxunHzrxlj(vo, session);
}

/**
* 发送临宿单
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/sendOrder")
public WgrsbVO sendOrder(HttpServletRequest request, WgrsbVO vo, HttpSession session) {
Locale local = localeResolver.resolveLocale(request);
return zssbService.fasongLinsuDan(local, vo, session);
}

// 文件下载相关代码
@RequestMapping(value = "/viewpdf")
public void download(WgrsbVO vo, HttpServletResponse response)
throws Exception {
zssbService.wenjianXiazai(vo,response);
}




}

SERVICE代码不展示大概1000行。。。

而一些判定填充实体类的操作,由于判定不同,方法不同,堆积在实体类方法也比较多,

接下来看怎样再次优化。

先抽根烟缓解下清理代码的恐慌。

PS:这边要求各种命名要拼音。。。