java笔记

java笔记

一、Controller

 	@Controller
	@RequestMapping(value="department")
  	@Autowired
    DepartmentService departmentService;
    
 	@RequestMapping(value = "doSave", method = {RequestMethod.POST, RequestMethod.GET})
	@ResponseBody
	public class DepartmentController extends BaseSpringController{
	public AjaxJson save(@RequestBody Department department){
		AjaxJson  result = new AjaxJson();
		logger.info("日程"+GsonUtil.toJson(department));
		try{
			String departmentId= schedule.getDepartmentId();
	 		if(!CheckUtil.isNull(department)){
	      		for(Department info : Department.getDepartments()){
	      				info .setDepartmentId(departmentId);
	      				info.setCreateDate(Calendar.getInstance().getTime());
	      		 		info.setModifiedDate(Calendar.getInstance().getTime());
	      		 		departmentService.createDepartment(info);
	     		 }
	     		 result.setSuccess(true);
	      		result.setObj(departmentId);
			 }else{
	     		logger.info("日程分享数据为空");
       			result.setSuccess(false);
        		result.setMsg("数据为空");
			 }
		}catch(Exception e) {
			logger.error(message:"异常",e);
			result.setSuccess(false);
			result.setMsg("数据异常")
		}
	}
}



public class Department{
	private String departmentId;
	private List<Department> departments;
	public String getDepartmentId(){
		return departmentId;
	}
	public void setDepartmentId(){
		this.departmentId = departmentId;
	}
	public List<Department>getDepartments(){
		return departments
	}
	public void setSchedules(List<Department> departments) {
    	this.departments= departments;
 }

}

service

接口

  public interface DepartmentService{
	void createDepartment(Department department);
  }

接口实现

  @service
	  public class departmentServiceImpl implements ISdepartmentService{
	  @Autowired
	  DepartmentMapper departmentMapper ;
	  @Override
      @Transactional(rollbackFor = Exception.class)
      public void createDepartment(Department  department){
     	 departmentMapper.insert(department) ;
      }
    }

dao

public interface DepartmentMapper{
	int insert(Department record)

}

xml

<mapper namespace="***model.DepartmentMapper" >
	<insert  id="insert" parameterType="***model.Department" >
			insert into department()
           values ()
	 </insert>
</mapper>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值