麻烦大哥帮我解读下这段语句,顺便讲解下待处理是如何显示给当前用户的
<select id="selectByNextDealSn" resultMap="claimVoucher" parameterType="String"> select cv.*,ce.name cname,ce.post cpost,d.name dname,d.post dpost from claim_voucher cv left join employee ce on ce.sn=cv.create_sn left join employee d on d.sn = cv.next_deal_sn where cv.next_deal_sn=#{ndsn} order by cv.create_time desc </select>
假如我登录的是经理账号,那是哪一段语句控制只显示给经理看的待处理报销单?
假如我登录的是员工账号,那是哪一段语句控制只显示给员工看的待处理报销单?
package com.imooc.oa.biz.Impl; import com.imooc.oa.biz.ClaimVoucherBiz; import com.imooc.oa.dao.ClaimVoucherDao; import com.imooc.oa.dao.ClaimVoucherItemDao; import com.imooc.oa.dao.DealRecordDao; import com.imooc.oa.dao.EmployeeDao; import com.imooc.oa.entity.ClaimVoucher; import com.imooc.oa.entity.ClaimVoucherItem; import com.imooc.oa.entity.DealRecord; import com.imooc.oa.entity.Employee; import com.imooc.oa.global.Contant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Service("claimVoucherBiz") public class ClaimVoucherBizImpl implements ClaimVoucherBiz { @Autowired private ClaimVoucherDao claimVoucherDao; @Autowired private ClaimVoucherItemDao claimVoucherItemDao; @Autowired private DealRecordDao dealRecordDao; @Autowired private EmployeeDao employeeDao; public void save(ClaimVoucher claimVoucher, List<ClaimVoucherItem> items) { claimVoucher.setCreateTime(new Date()); claimVoucher.setNextDealSn(claimVoucher.getCreateSn()); claimVoucher.setStatus(Contant.CLAIMVOUCHER_CREATED); claimVoucherDao.insert(claimVoucher); for (ClaimVoucherItem item : items) { item.setClaimVoucherId(claimVoucher.getId());//不明白 claimVoucherItemDao.insert(item); } } public ClaimVoucher get(int id) { return claimVoucherDao.select(id); } public List<ClaimVoucherItem> getItems(int cvid) { return claimVoucherItemDao.selectByClaimVoucher(cvid); } public List<DealRecord> getRecords(int cvid) { return dealRecordDao.selectByClaimVoucher(cvid); } public List<ClaimVoucher> getforSelf(String sn) { return claimVoucherDao.selectByCreateSn(sn); } public List<ClaimVoucher> getforDeal(String sn) { return claimVoucherDao.selectByNextDealSn(sn); } public void update(ClaimVoucher claimVoucher, List<ClaimVoucherItem> items) { claimVoucher.setNextDealSn(claimVoucher.getCreateSn()); claimVoucher.setStatus(Contant.CLAIMVOUCHER_CREATED); claimVoucherDao.update(claimVoucher); List<ClaimVoucherItem> olds = claimVoucherItemDao.selectByClaimVoucher(claimVoucher.getId()); for (ClaimVoucherItem old : olds) { boolean isHave = false; for (ClaimVoucherItem item : items) { if (item.getId() == old.getId()) { isHave = true; break; } } //这里看不懂 if (!isHave) { claimVoucherItemDao.delete(old.getId()); } } for (ClaimVoucherItem item : items) { //不理解 item.setClaimVoucherId(claimVoucher.getId()); if (item.getId() != null && item.getId() > 0) { claimVoucherItemDao.update(item); } else { claimVoucherItemDao.insert(item); } } } public void submit(int id) { ClaimVoucher claimVoucher = claimVoucherDao.select(id); Employee employee = employeeDao.select(claimVoucher.getCreateSn()); claimVoucher.setStatus(Contant.CLAIMVOUCHER_SUBMIT); claimVoucher.setNextDealSn(employeeDao.selectByDepartmentAndPost(employee.getDepartmentSn(), Contant.POST_FM).get(0).getSn()); claimVoucherDao.update(claimVoucher); DealRecord dealRecord = new DealRecord(); dealRecord.setDealWay(Contant.DEAL_SUBMIT); dealRecord.setDealSn(employee.getSn()); dealRecord.setClaimVoucherId(id); dealRecord.setDealResult(Contant.CLAIMVOUCHER_SUBMIT); dealRecord.setDealTime(new Date()); dealRecord.setComment("无"); dealRecordDao.insert(dealRecord); } }
package com.imooc.oa.controller; import com.imooc.oa.biz.ClaimVoucherBiz; import com.imooc.oa.dto.ClaimVoucherInfo; import com.imooc.oa.entity.Employee; import com.imooc.oa.global.Contant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpSession; import java.util.Map; @Controller("claimVoucherController") @RequestMapping("/claim_voucher") public class ClaimVoucherController { @Autowired private ClaimVoucherBiz claimVoucherBiz; @RequestMapping("/to_add") public String toAdd(Map<String, Object> map) { map.put("items", Contant.getItems()); map.put("info", new ClaimVoucherInfo()); return "claim_voucher_add"; } @RequestMapping("/add") public String add(HttpSession session, ClaimVoucherInfo info) { Employee employee = (Employee) session.getAttribute("employee"); info.getClaimVoucher().setCreateSn(employee.getSn()); claimVoucherBiz.save(info.getClaimVoucher(), info.getItems()); return "redirect:detail?id=" + info.getClaimVoucher().getId(); } //为什么链接的id跟这个方法对应? @RequestMapping("/detail") public String detail(int id, Map<String, Object> map) { map.put("claimVoucher", claimVoucherBiz.get(id)); map.put("items", claimVoucherBiz.getItems(id)); map.put("records", claimVoucherBiz.getRecords(id)); return "claim_voucher_detail"; } @RequestMapping("/self") public String self(HttpSession session, Map<String, Object> map) { Employee employee = (Employee) session.getAttribute("employee"); map.put("list", claimVoucherBiz.getforSelf(employee.getSn())); return "claim_voucher_self"; } @RequestMapping("/deal") public String deal(HttpSession session, Map<String, Object> map) { Employee employee = (Employee) session.getAttribute("employee"); map.put("list", claimVoucherBiz.getforDeal(employee.getSn())); return "claim_voucher_deal"; } @RequestMapping("/to_update") public String toUpdate(int id, Map<String, Object> map) { map.put("items", Contant.getItems()); ClaimVoucherInfo info = new ClaimVoucherInfo(); info.setClaimVoucher(claimVoucherBiz.get(id)); info.setItems(claimVoucherBiz.getItems(id)); map.put("info", info); return "claim_voucher_update"; } @RequestMapping("/update") public String update(HttpSession session, ClaimVoucherInfo info) { Employee employee = (Employee) session.getAttribute("employee"); info.getClaimVoucher().setCreateSn(employee.getSn()); claimVoucherBiz.update(info.getClaimVoucher(), info.getItems()); return "redirect:deal"; } @RequestMapping("/submit") public String submit(int id) { claimVoucherBiz.submit(id); return "redirect:deal"; } }
是哪段代码做了判断呢?
3
收起
正在回答 回答被采纳积分+1
1回答
SSM主流框架入门与综合项目实战2018版
- 参与学习 人
- 提交作业 205 份
- 解答问题 4317 个
Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星