package com.ygj.yuemum.service.customer; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.ygj.yuemum.dao.customer.CustomerInfoBasicDao; import com.ygj.yuemum.domain.admin.JlAdminUser; import com.ygj.yuemum.domain.customer.CustomerInfoBasic; import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog; import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicCyDto; import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicDto; import com.ygj.yuemum.service.admin.JlAdminUserService; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * customer_info_basic * @author zrz * @date 2020/06/17 */ @Service public class CustomerInfoBasicService { @Resource private CustomerInfoBasicDao customerInfoBasicDao; @Resource CustomerInfoServiceLogService customerInfoServiceLogService; @Resource JlAdminUserService jladminuserService; public int insert(CustomerInfoBasic customerInfoBasic) { this.setDefValue(customerInfoBasic); int count = customerInfoBasicDao.insert(customerInfoBasic); if (count != 0) { this.insertServiceLog(customerInfoBasic.getId(), "新增", customerInfoBasic); return count; } return 0; } public int delete(int id) { int ret = customerInfoBasicDao.delete(id); return ret; } public int update(CustomerInfoBasic customerInfoBasic) { this.insertServiceLog(customerInfoBasic.getId(), "修改", customerInfoBasic); int ret = customerInfoBasicDao.update(customerInfoBasic); return ret; } public CustomerInfoBasic load(int id) { return customerInfoBasicDao.load(id); } public Map pageList(int offset, int pagesize) { List pageList = customerInfoBasicDao.pageList(offset, pagesize); int totalCount = customerInfoBasicDao.pageListCount(offset, pagesize); // result Map result = new HashMap(); result.put("pageList", pageList); result.put("totalCount", totalCount); return result; } public List selectByPageNumSize(CustomerInfoBasicDto customerInfoBasic) { PageHelper.startPage(customerInfoBasic.getPage(), customerInfoBasic.getLimit(), true, false); return customerInfoBasicDao.selectByPageNumSize(customerInfoBasic); } public void insertInfoBasicList(List list) { customerInfoBasicDao.insertInfoBasicList(list); } private void insertServiceLog(Integer sl_no, String type, CustomerInfoBasic customerInfoBasic) { JlAdminUser jlAdminUser = jladminuserService.getUserByDefPrincipal(); CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog(); customerInfoServiceLog.setSl_userid(jlAdminUser.getId()); customerInfoServiceLog.setSl_username(jlAdminUser.getName()); customerInfoServiceLog.setSl_createdate(new Date()); customerInfoServiceLog.setSl_no(sl_no); customerInfoServiceLog.setSl_table("customer_info_basic"); customerInfoServiceLog.setSl_type(type); customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoBasic)); customerInfoServiceLogService.insert(customerInfoServiceLog); } private void setDefValue(CustomerInfoBasic customerInfoBasic) { if (StringUtils.isBlank(customerInfoBasic.getFb_customer_name())) { customerInfoBasic.setFb_customer_name(""); } if (StringUtils.isBlank(customerInfoBasic.getFb_customer_phone())) { customerInfoBasic.setFb_customer_phone(""); } } }