package com.dsh.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.dsh.guns.config.UserExt;
|
import com.dsh.guns.core.base.controller.BaseController;
|
import com.dsh.guns.core.log.LogObjectHolder;
|
import com.dsh.guns.modular.system.model.TbVoice;
|
import com.dsh.guns.modular.system.service.ITbVoiceService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.MediaType;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
import java.util.List;
|
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2022-06-17 14:43:39
|
*/
|
@Controller
|
@RequestMapping("/TVoice")
|
public class TVoiceController extends BaseController {
|
|
private String PREFIX = "/system/tVoice/";
|
|
@Autowired
|
private ITbVoiceService tbVoiceService;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index(Model model) {
|
model.addAttribute("language", UserExt.getLanguage());
|
return PREFIX + "tbVoice.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tbVoice_add")
|
public String tbVoiceAdd(Model model) {
|
model.addAttribute("language1",UserExt.getLanguage());
|
return PREFIX + "tbVoice_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tbVoice_update/{tbVoiceId}")
|
public String tbVoiceUpdate(@PathVariable Integer tbVoiceId, Model model) {
|
TbVoice tbVoice = tbVoiceService.getById(tbVoiceId);
|
model.addAttribute("item",tbVoice);
|
model.addAttribute("language1",UserExt.getLanguage());
|
LogObjectHolder.me().set(tbVoice);
|
return PREFIX + "tbVoice_edit.html";
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public List<TbVoice> list(String name , Integer state) {
|
return tbVoiceService.getList(name,state);
|
}
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(Integer language,String url,Integer userType, String name) {
|
List<TbVoice> list = tbVoiceService.list(new LambdaQueryWrapper<TbVoice>().eq(TbVoice::getVoiceType, userType).eq(TbVoice::getLanguage,language).ne(TbVoice::getState,3));
|
if(list.size()>0){
|
return "504";
|
}
|
|
TbVoice tbVoice = new TbVoice();
|
tbVoice.setState(1);
|
tbVoice.setCreateTime(new Date());
|
tbVoice.setLanguage(language);
|
tbVoice.setVoiceType(userType);
|
tbVoice.setUrl(url);
|
// tbVoice.setInsertTime(new Date());
|
tbVoice.setName(name);
|
// tbVoice.setPublisher(ShiroKit.getUser().getName());
|
tbVoiceService.save(tbVoice);
|
return SUCCESS_TIP;
|
}
|
|
// public static void main(String[] args) {
|
// String a ="C:\\fakepath\\998e5510ea7fc3d1733ec901e778988f.jpg";
|
// String[] split = a.split("\\.");
|
// String s = split[split.length-1];
|
// int i = a.lastIndexOf("\\")+1;
|
// int i1 = a.lastIndexOf(".");
|
// String substring = a.substring(i, i1);
|
// System.out.println(substring);
|
// }
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer TVoiceId) {
|
TbVoice byId = tbVoiceService.getById(TVoiceId);
|
byId.setState(3);
|
tbVoiceService.updateById(byId);
|
return SUCCESS_TIP;
|
}
|
@RequestMapping(value = "/start")
|
@ResponseBody
|
public Object start(@RequestParam Integer TVoiceId) {
|
TbVoice byId = tbVoiceService.getById(TVoiceId);
|
byId.setState(1);
|
tbVoiceService.updateById(byId);
|
return SUCCESS_TIP;
|
}
|
@RequestMapping(value = "/stop")
|
@ResponseBody
|
public Object stop(@RequestParam Integer TVoiceId) {
|
TbVoice byId = tbVoiceService.getById(TVoiceId);
|
byId.setState(2);
|
tbVoiceService.updateById(byId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(Integer id,Integer language,String url,Integer userType) {
|
List<TbVoice> list = tbVoiceService.list(new LambdaQueryWrapper<TbVoice>().eq(TbVoice::getVoiceType, userType).eq(TbVoice::getLanguage,language).ne(TbVoice::getId, id).ne(TbVoice::getState,3));
|
if(list.size()>0){
|
return "504";
|
}
|
|
|
TbVoice byId = tbVoiceService.getById(id);
|
byId.setLanguage(language);
|
byId.setUrl(url);
|
byId.setVoiceType(userType);
|
int i = url.lastIndexOf("\\")+1;
|
int i1 = url.lastIndexOf(".");
|
String substring = url.substring(i, i1);
|
byId.setName(substring);
|
tbVoiceService.updateById(byId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tbVoiceId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tbVoiceId") Integer tbVoiceId) {
|
return tbVoiceService.getById(tbVoiceId);
|
}
|
}
|