提交 ecfeb646 authored 作者: 吴德鹏's avatar 吴德鹏

加入处理代码

上级 059c44de
package com.platform.controller;
import com.platform.entity.DealEntity;
import com.platform.service.DealService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author lipengjun
* @date 2020-06-22 11:09:19
*/
@Controller
@RequestMapping("deal")
public class DealController {
@Autowired
private DealService dealService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("deal:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<DealEntity> dealList = dealService.queryList(query);
int total = dealService.queryTotal(query);
PageUtils pageUtil = new PageUtils(dealList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("deal:info")
@ResponseBody
public R info(@PathVariable("id") String id) {
DealEntity deal = dealService.queryObject(id);
return R.ok().put("deal", deal);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("deal:save")
@ResponseBody
public R save(@RequestBody DealEntity deal) {
dealService.save(deal);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("deal:update")
@ResponseBody
public R update(@RequestBody DealEntity deal) {
dealService.update(deal);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("deal:delete")
@ResponseBody
public R delete(@RequestBody String[] ids) {
dealService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<DealEntity> list = dealService.queryList(params);
return R.ok().put("list", list);
}
}
package com.platform.dao;
import com.platform.entity.DealEntity;
/**
* Dao
*
* @author lipengjun
* @date 2020-06-22 11:09:19
*/
public interface DealDao extends BaseDao<DealEntity> {
}
package com.platform.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 deal
*
* @author lipengjun
* @date 2020-06-22 11:09:19
*/
public class DealEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 处理ID
*/
private String id;
/**
* 被处理人
*/
private String userId;
/**
* 1:不处理 2:禁言 3:禁帖 4:禁言/禁帖
*/
private Integer result;
/**
* 处理人
*/
private String dealUserId;
/**
* 处理原因
*/
private String reason;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateDate;
/**
* 设置:处理ID
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取:处理ID
*/
public String getId() {
return id;
}
/**
* 设置:被处理人
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* 获取:被处理人
*/
public String getUserId() {
return userId;
}
/**
* 设置:1:不处理 2:禁言 3:禁帖 4:禁言/禁帖
*/
public void setResult(Integer result) {
this.result = result;
}
/**
* 获取:1:不处理 2:禁言 3:禁帖 4:禁言/禁帖
*/
public Integer getResult() {
return result;
}
/**
* 设置:处理人
*/
public void setDealUserId(String dealUserId) {
this.dealUserId = dealUserId;
}
/**
* 获取:处理人
*/
public String getDealUserId() {
return dealUserId;
}
/**
* 设置:处理原因
*/
public void setReason(String reason) {
this.reason = reason;
}
/**
* 获取:处理原因
*/
public String getReason() {
return reason;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:更新时间
*/
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
/**
* 获取:更新时间
*/
public Date getUpdateDate() {
return updateDate;
}
}
package com.platform.service;
import com.platform.entity.DealEntity;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2020-06-22 11:09:19
*/
public interface DealService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
DealEntity queryObject(String id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<DealEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param deal 实体
* @return 保存条数
*/
int save(DealEntity deal);
/**
* 根据主键更新实体
*
* @param deal 实体
* @return 更新条数
*/
int update(DealEntity deal);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(String id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(String[] ids);
}
package com.platform.service.impl;
import com.platform.dao.DealDao;
import com.platform.entity.DealEntity;
import com.platform.service.DealService;
import com.platform.utils.IdUtil;
import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2020-06-22 11:09:19
*/
@Service("dealService")
public class DealServiceImpl implements DealService {
@Autowired
private DealDao dealDao;
@Override
public DealEntity queryObject(String id) {
return dealDao.queryObject(id);
}
@Override
public List<DealEntity> queryList(Map<String, Object> map) {
return dealDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return dealDao.queryTotal(map);
}
@Override
public int save(DealEntity deal) {
deal.setId(IdUtil.createIdbyUUID());
deal.setDealUserId(ShiroUtils.getUserId());
deal.setCreateTime(new Date());
deal.setUpdateDate(new Date());
return dealDao.save(deal);
}
@Override
public int update(DealEntity deal) {
deal.setUpdateDate(new Date());
return dealDao.update(deal);
}
@Override
public int delete(String id) {
return dealDao.delete(id);
}
@Override
public int deleteBatch(String[] ids) {
return dealDao.deleteBatch(ids);
}
}
<?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="com.platform.dao.DealDao">
<resultMap type="com.platform.entity.DealEntity" id="dealMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="result" column="result"/>
<result property="dealUserId" column="deal_user_id"/>
<result property="reason" column="reason"/>
<result property="createTime" column="create_time"/>
<result property="updateDate" column="update_date"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.DealEntity">
select
`id`,
`user_id`,
`result`,
`deal_user_id`,
`reason`,
`create_time`,
`update_date`
from deal
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.DealEntity">
select
`id`,
`user_id`,
`result`,
`deal_user_id`,
`reason`,
`create_time`,
`update_date`
from deal
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from deal
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.DealEntity">
insert into deal(
`id`,
`user_id`,
`result`,
`deal_user_id`,
`reason`,
`create_time`,
`update_date`)
values(
#{id},
#{userId},
#{result},
#{dealUserId},
#{reason},
#{createTime},
#{updateDate})
</insert>
<update id="update" parameterType="com.platform.entity.DealEntity">
update deal
<set>
<if test="userId != null">`user_id` = #{userId}, </if>
<if test="result != null">`result` = #{result}, </if>
<if test="dealUserId != null">`deal_user_id` = #{dealUserId}, </if>
<if test="reason != null">`reason` = #{reason}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateDate != null">`update_date` = #{updateDate}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from deal where id = #{value}
</delete>
<delete id="deleteBatch">
delete from deal where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论