package io.renren.modules.app.controller; import java.util.Arrays; import java.util.Map; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; import io.renren.modules.app.entity.TicketsEntity; import io.renren.modules.app.service.TicketsService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * 工单表 * * @author Alatus * @email * @date 2024-06-11 15:08:46 */ @RestController @RequestMapping("mall/tickets") public class TicketsController { @Autowired private TicketsService ticketsService; /** * 列表 */ @GetMapping("/list") @RequiresPermissions("sys:ticket:manage") // @RequiresRoles("admin") public R list(@RequestParam Map<String, Object> params){ // 2、可以通过工单名称与客户名称进行模糊搜索 // 3、可以通过工单处理状态检索筛选 PageUtils page = ticketsService.queryPage(params); return R.ok().put("page", page); } /** * 信息 */ @GetMapping("/info/{id}") @RequiresPermissions("sys:ticket:manage") public R info(@PathVariable("id") Long id){ TicketsEntity tickets = ticketsService.getById(id); return R.ok().put("tickets", tickets); } /** * 保存 */ @PostMapping("/save") public R save(@RequestBody TicketsEntity tickets){ ticketsService.save(tickets); return R.ok(); } /** * 修改 */ @PutMapping("/update") @RequiresPermissions("sys:ticket:manage") public R update(@RequestBody TicketsEntity tickets){ TicketsEntity entity = ticketsService.getById(tickets.getId()); // BeanUtils.copyProperties(entity,tickets); entity.setHandler(tickets.getHandler()); entity.setSuggestion(tickets.getSuggestion()); entity.setStatus(1); ticketsService.updateById(entity); return R.ok(); } /** * 删除 */ @RequestMapping("/delete") @RequiresPermissions("sys:ticket:manage") public R delete(@RequestBody Long[] ids){ ticketsService.removeByIds(Arrays.asList(ids)); return R.ok(); } }
package io.renren.modules.app.controller;
import java.util.Arrays;
import java.util.Map;import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.TicketsEntity;
import io.renren.modules.app.service.TicketsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 工单表
*
* @author Alatus
* @date 2024-06-11 15:08:46
*/
@RestController
@RequestMapping("mall/tickets")
public class TicketsController {
@Autowired
private TicketsService ticketsService;
/**
* 列表
*/@GetMapping("/list")
@RequiresPermissions("sys:ticket:manage")
// @RequiresRoles("admin")
public R list(@RequestParam Map<String, Object> params){
// 2、可以通过工单名称与客户名称进行模糊搜索
// 3、可以通过工单处理状态检索筛选
PageUtils page = ticketsService.queryPage(params);return R.ok().put("page", page);
}
/**
* 信息
*/
@GetMapping("/info/{id}")
@RequiresPermissions("sys:ticket:manage")
public R info(@PathVariable("id") Long id){
TicketsEntity tickets = ticketsService.getById(id);return R.ok().put("tickets", tickets);
}/**
* 保存
*/
@PostMapping("/save")
public R save(@RequestBody TicketsEntity tickets){
ticketsService.save(tickets);return R.ok();
}/**
* 修改
*/
@PutMapping("/update")
@RequiresPermissions("sys:ticket:manage")
public R update(@RequestBody TicketsEntity tickets){
TicketsEntity entity = ticketsService.getById(tickets.getId());
// BeanUtils.copyProperties(entity,tickets);
entity.setHandler(tickets.getHandler());
entity.setSuggestion(tickets.getSuggestion());
entity.setStatus(1);
ticketsService.updateById(entity);
return R.ok();
}/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("sys:ticket:manage")
public R delete(@RequestBody Long[] ids){
ticketsService.removeByIds(Arrays.asList(ids));return R.ok();
}}
package io.renren.modules.app.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import io.renren.modules.app.entity.TicketsEntity; import org.apache.ibatis.annotations.Mapper; /** * 工单表 * * @author Alatus * @email * @date 2024-06-11 15:08:46 */ @Mapper public interface TicketsDao extends BaseMapper<TicketsEntity> { Integer deleteByIds(Long[] ids); }
package io.renren.modules.app.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.app.entity.TicketsEntity;
import org.apache.ibatis.annotations.Mapper;/**
* 工单表
*
* @author Alatus
* @date 2024-06-11 15:08:46
*/
@Mapper
public interface TicketsDao extends BaseMapper<TicketsEntity> {Integer deleteByIds(Long[] ids);
}
package io.renren.modules.app.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.util.Date; import lombok.Data; /** * 工单表 * * @author Alatus * @email * @date 2024-06-11 15:08:46 */ @Data @TableName("tickets") public class TicketsEntity implements Serializable { private static final long serialVersionUID = 1L; /** * 工单编号(主键) */ @TableId private Long id; /** * 客户姓名 */ private String customerName; /** * 联系电话 */ private String contactPhone; /** * 工单标题 */ private String title; /** * 问题描述 */ private String description; /** * 处理状态 */ private Integer status; /** * 处理建议 */ private String suggestion; /** * 处理人 */ private String handler; /** * 工单提交时间 */ private Date submitTime; /** * 逻辑删除标志 */ private Integer isDeleted; }
package io.renren.modules.app.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;import java.io.Serializable;
import java.util.Date;
import lombok.Data;/**
* 工单表
*
* @author Alatus
* @date 2024-06-11 15:08:46
*/
@Data
@TableName("tickets")
public class TicketsEntity implements Serializable {
private static final long serialVersionUID = 1L;/**
* 工单编号(主键)
*/
@TableId
private Long id;
/**
* 客户姓名
*/
private String customerName;
/**
* 联系电话
*/
private String contactPhone;
/**
* 工单标题
*/
private String title;
/**
* 问题描述
*/
private String description;
/**
* 处理状态
*/
private Integer status;
/**
* 处理建议
*/
private String suggestion;
/**
* 处理人
*/
private String handler;
/**
* 工单提交时间
*/
private Date submitTime;
/**
* 逻辑删除标志
*/
private Integer isDeleted;}
package io.renren.modules.app.service; import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.app.entity.TicketsEntity; import java.util.Map; /** * 工单表 * * @author Alatus * @email * @date 2024-06-11 15:08:46 */ public interface TicketsService extends IService<TicketsEntity> { PageUtils queryPage(Map<String, Object> params); Integer removeByIds(Long[] ids); }
package io.renren.modules.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.renren.common.utils.PageUtils;
import io.renren.modules.app.entity.TicketsEntity;import java.util.Map;
/**
* 工单表
*
* @author Alatus
* @date 2024-06-11 15:08:46
*/
public interface TicketsService extends IService<TicketsEntity> {PageUtils queryPage(Map<String, Object> params);
Integer removeByIds(Long[] ids);
}
package io.renren.modules.app.service.impl; import io.renren.common.utils.PageUtils; import io.renren.common.utils.Query; import io.renren.modules.app.dao.TicketsDao; import io.renren.modules.app.entity.TicketsEntity; import io.renren.modules.app.service.TicketsService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @Service("ticketsService") public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> implements TicketsService { @Autowired private TicketsDao ticketsDao; @Override public PageUtils queryPage(Map<String, Object> params) { // 获取key做模糊查询 String key = (String) params.get("key"); QueryWrapper<TicketsEntity> queryWrapper = new QueryWrapper<>(); if(!StringUtils.isEmpty(key)){ queryWrapper.eq("title",key).or().like("customer_name",key).eq("is_deleted",0); } IPage<TicketsEntity> page = this.page( new Query<TicketsEntity>().getPage(params), queryWrapper ); return new PageUtils(page); } @Override public Integer removeByIds(Long[] ids) { Integer count = ticketsDao.deleteByIds(ids); return count; } }
package io.renren.modules.app.service.impl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.app.dao.TicketsDao;
import io.renren.modules.app.entity.TicketsEntity;
import io.renren.modules.app.service.TicketsService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@Service("ticketsService")
public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> implements TicketsService {
@Autowired
private TicketsDao ticketsDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
// 获取key做模糊查询
String key = (String) params.get("key");
QueryWrapper<TicketsEntity> queryWrapper = new QueryWrapper<>();
if(!StringUtils.isEmpty(key)){
queryWrapper.eq("title",key).or().like("customer_name",key).eq("is_deleted",0);
}
IPage<TicketsEntity> page = this.page(
new Query<TicketsEntity>().getPage(params),
queryWrapper
);
return new PageUtils(page);
}@Override
public Integer removeByIds(Long[] ids) {
Integer count = ticketsDao.deleteByIds(ids);
return count;
}
}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="io.renren.modules.app.dao.TicketsDao"> <!-- 可根据自己的需求,是否要使用 --> <resultMap type="io.renren.modules.app.entity.TicketsEntity" id="ticketsMap"> <result property="id" column="id"/> <result property="customerName" column="customer_name"/> <result property="contactPhone" column="contact_phone"/> <result property="title" column="title"/> <result property="description" column="description"/> <result property="status" column="STATUS"/> <result property="suggestion" column="suggestion"/> <result property="handler" column="HANDLER"/> <result property="submitTime" column="submit_time"/> <result property="isDeleted" column="is_deleted"/> </resultMap> <update id="deleteByIds"> update tickets set is_deleted = 1 where id in ( <foreach collection="array" item="id" separator=","> #{id} </foreach> ) </update> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="io.renren.modules.app.dao.TicketsDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.renren.modules.app.entity.TicketsEntity" id="ticketsMap">
<result property="id" column="id"/>
<result property="customerName" column="customer_name"/>
<result property="contactPhone" column="contact_phone"/>
<result property="title" column="title"/>
<result property="description" column="description"/>
<result property="status" column="STATUS"/>
<result property="suggestion" column="suggestion"/>
<result property="handler" column="HANDLER"/>
<result property="submitTime" column="submit_time"/>
<result property="isDeleted" column="is_deleted"/>
</resultMap>
<update id="deleteByIds">
update tickets
set is_deleted = 1
where id in (
<foreach collection="array" item="id" separator=",">
#{id}
</foreach>
)
</update>
</mapper>