package com.sinata.modular.system.controller;
|
|
import com.sinata.common.enums.EnumIsDelete;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.util.DateUtils2;
|
import com.sinata.core.util.ExcelExportUtil;
|
import com.sinata.modular.member.model.MemMerchant;
|
import com.sinata.modular.member.service.IMemMerchantService;
|
import com.sinata.modular.system.model.AreaCity;
|
import com.sinata.modular.system.service.IAreaCityService;
|
import com.sinata.modular.system.service.RedisTemplateService;
|
import org.springframework.stereotype.Controller;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.sinata.core.common.annotion.BussinessLog;
|
import com.sinata.core.common.annotion.Permission;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.sinata.core.log.LogObjectHolder;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import com.sinata.modular.system.model.MyDoctor;
|
import com.sinata.modular.system.service.IMyDoctorService;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
import org.springframework.util.StringUtils;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
/**
|
* 美牙医生控制器
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/myDoctor")
|
public class MyDoctorController extends BaseController {
|
|
private String PREFIX = "/system/myDoctor/";
|
|
@Autowired
|
private IMyDoctorService myDoctorService;
|
|
@Autowired
|
private IMemMerchantService merchantService;
|
|
@Autowired
|
private RedisTemplateService redis;
|
|
@Autowired
|
private IAreaCityService areaCityService;
|
|
/**
|
* 跳转到美牙医生首页
|
*/
|
@RequestMapping("")
|
public String index(Model model) {
|
Wrapper wrapper2 = new EntityWrapper<AreaCity>().orderBy("id", false);
|
wrapper2.eq("is_open",1);
|
wrapper2.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("cityAreaList",areaCityService.selectList(wrapper2));
|
return PREFIX + "myDoctor.html";
|
}
|
|
/**
|
* 跳转到添加美牙医生
|
*/
|
@RequestMapping("/myDoctor_add")
|
public String myDoctorAdd(Model model) {
|
Page<MemMerchant> page = new PageFactory().defaultPage(999999,0);
|
// 查询数据列表
|
List<MemMerchant> list = merchantService.queryMerchantList(page, null, null, null, null, null, null);
|
model.addAttribute("merchantList",list);
|
Wrapper wrapper2 = new EntityWrapper<AreaCity>().orderBy("id", false);
|
wrapper2.eq("is_open",1);
|
wrapper2.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("cityAreaList",areaCityService.selectList(wrapper2));
|
return PREFIX + "myDoctor_add.html";
|
}
|
|
/**
|
* 跳转到修改美牙医生
|
*/
|
@RequestMapping("/myDoctor_update/{myDoctorId}")
|
public String myDoctorUpdate(@PathVariable Integer myDoctorId, Model model) {
|
Page<MemMerchant> page = new PageFactory().defaultPage(999999,0);
|
// 查询数据列表
|
List<MemMerchant> list = merchantService.queryMerchantList(page, null, null, null, null, null, null);
|
model.addAttribute("merchantList",list);
|
MyDoctor myDoctor = myDoctorService.selectById(myDoctorId);
|
model.addAttribute("item",myDoctor);
|
Wrapper wrapper2 = new EntityWrapper<AreaCity>().orderBy("id", false);
|
wrapper2.eq("is_open",1);
|
wrapper2.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("cityAreaList",areaCityService.selectList(wrapper2));
|
LogObjectHolder.me().set(myDoctor);
|
return PREFIX + "myDoctor_edit.html";
|
}
|
|
/**
|
* 获取美牙医生列表
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String condition,Integer cityId,Integer sex,Integer workTime) {
|
Page<MyDoctor> page = new PageFactory().defaultPage();
|
|
// 时间搜索
|
if(!StringUtils.isEmpty(beginTime)) {
|
beginTime = beginTime + " 00:00:00";
|
}
|
if(!StringUtils.isEmpty(endTime)) {
|
endTime = endTime + " 23:59:59";
|
}
|
|
// 查询数据列表
|
List<MyDoctor> list = myDoctorService.queryMyDoctorList( beginTime, endTime, condition, cityId, sex, workTime,page);
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增美牙医生
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增美牙医生")
|
@RequestMapping(value = "/add")
|
public Object add(MyDoctor myDoctor) {
|
myDoctorService.insert(myDoctor);
|
return SUCCESS_TIP;
|
}
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除美牙医生")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
myDoctorService.updateForSet("is_delete = 1", new EntityWrapper<MyDoctor>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改美牙医生
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改美牙医生")
|
@RequestMapping(value = "/update")
|
public Object update(MyDoctor myDoctor) {
|
myDoctorService.updateById(myDoctor);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改美牙医生状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改美牙医生状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(Integer myDoctorId, Integer state) {
|
myDoctorService.updateForSet("state = " + state, new EntityWrapper<MyDoctor>().eq("id", myDoctorId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转美牙医生详情
|
*/
|
@RequestMapping(value = "/detail/{myDoctorId}")
|
public Object detail(@PathVariable("myDoctorId") Integer myDoctorId, Model model) {
|
Page<MemMerchant> page = new PageFactory().defaultPage(999999,0);
|
// 查询数据列表
|
List<MemMerchant> list = merchantService.queryMerchantList(page,null, null, null, null, null, null);
|
model.addAttribute("merchantList",list);
|
MyDoctor myDoctor = myDoctorService.selectById(myDoctorId);
|
model.addAttribute("item",myDoctor);
|
Wrapper wrapper2 = new EntityWrapper<AreaCity>().orderBy("id", false);
|
wrapper2.eq("is_open",1);
|
wrapper2.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("cityAreaList",areaCityService.selectList(wrapper2));
|
LogObjectHolder.me().set(myDoctor);
|
return PREFIX + "myDoctor_detail.html";
|
}
|
|
@RequestMapping(value = "/export")
|
@ResponseBody
|
public Object export(String beginTime, String endTime, String condition,Integer cityId,Integer sex,Integer workTime,HttpServletResponse response) {
|
Page<MyDoctor> page = new PageFactory().defaultPage(999999,0);
|
|
// 时间搜索
|
if(!StringUtils.isEmpty(beginTime)) {
|
beginTime = beginTime + " 00:00:00";
|
}
|
if(!StringUtils.isEmpty(endTime)) {
|
endTime = endTime + " 23:59:59";
|
}
|
|
// 查询数据列表
|
List<MyDoctor> list = myDoctorService.queryMyDoctorList( beginTime, endTime, condition, cityId, sex, workTime,page);
|
|
|
// 表格数据【封装】
|
List<List<Object>> dataList = new ArrayList<>();
|
|
// 头部列【封装】
|
List<Object> shellList = new ArrayList<>();
|
shellList.add("添加时间");
|
shellList.add("医生头像");
|
shellList.add("医生名称");
|
shellList.add("所在城市");
|
shellList.add("所在门店");
|
shellList.add("入职时间");
|
shellList.add("性别");
|
shellList.add("联系电话");
|
shellList.add("职级");
|
shellList.add("擅长领域");
|
shellList.add("个人介绍");
|
shellList.add("从业年限");
|
dataList.add(shellList);
|
|
// 详细数据列【封装】
|
for (MyDoctor map : list) {
|
shellList = new ArrayList<>();
|
shellList.add(DateUtils2.getTime(map.getCreateTime()));
|
shellList.add( map.getAvatar());
|
shellList.add( map.getName());
|
shellList.add( map.getCityName());
|
shellList.add( map.getMerchantName());
|
shellList.add(DateUtils2.getTime(map.getJoinTime()));
|
shellList.add( map.getSex().equals("1")?"男":"女");
|
shellList.add( map.getPhone());
|
shellList.add( map.getPosition());
|
shellList.add( map.getTechnique());
|
shellList.add( map.getRemark());
|
shellList.add( map.getWorkTimeNum());
|
dataList.add( shellList);
|
}
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("导出数据"+ DateUtils2.formatDate(new Date(), "YYYYMMddHHmmSS"), "导出数据", dataList, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
@RequestMapping(value = "/title/image")
|
public Object titleImage( Model model) {
|
Object doctor_title_image = "";
|
try {
|
doctor_title_image = redis.get("DOCTOR_TITLE_IMAGE");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
model.addAttribute("item", doctor_title_image);
|
return PREFIX + "myDoctorImage.html";
|
}
|
|
@RequestMapping(value = "/set/title/image")
|
@ResponseBody
|
public Object setTitleImage(String image) {
|
redis.set("DOCTOR_TITLE_IMAGE",image);
|
return SUCCESS_TIP;
|
}
|
}
|