Commit 4917253c by mobh

消息模板功能

parent 906784c3
......@@ -38,9 +38,6 @@ public class AdminMsgTemplate extends Model<AdminMsgTemplate> {
@ApiModelProperty(value="id id",example="101")
private Integer id;
@ApiModelProperty(value="模板编号 ",example="模板ID")
private String templateNum;
@ApiModelProperty(value="模板名称 ",example="模板名称")
private String templateName;
......@@ -60,7 +57,7 @@ public class AdminMsgTemplate extends Model<AdminMsgTemplate> {
private Integer state;
@ApiModelProperty(value="生产时间 生产时间",example="101")
private Integer addtime;
private Long addtime;
@ApiModelProperty(value="企业ID 企业ID",example="101")
private Integer orgCode;
......
package cn.timer.api.controller.admin;
import cn.timer.api.bean.admin.AdminMsgTemplate;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.admin.AdminMsgTemplateMapper;
import cn.timer.api.dto.admin.AdminMsgTemplateDto;
import cn.timer.api.dto.xcgl.FixedSalaryStaffDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Api(tags = "消息模板管理")
@RestController
@Transactional
@RequestMapping(value = "/msg")
@RequestMapping(value = "/msg")
public class AdminMsgTemplateController {
@Resource
......@@ -30,9 +31,62 @@ public class AdminMsgTemplateController {
@PostMapping("/listMsgTemplate")
@ApiOperation(value = "列出消息模板", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> listMsgTemplate(@CurrentUser UserBean userBean, @RequestBody AdminMsgTemplateDto dto) {
dto.setOrgCode(userBean.getOrgCode());
List<AdminMsgTemplate> list = msgTemplateMapper.listMsgTemplate(dto);
public Result<Object> listMsgTemplate(@CurrentUser UserBean userBean, @RequestBody AdminMsgTemplateDto search) {
search.setOrgCode(userBean.getOrgCode());
List<AdminMsgTemplate> list = msgTemplateMapper.listMsgTemplate(search);
return ResultUtil.data(list);
}
@PostMapping("/pageMsgTemplate")
@ApiOperation(value = "消息模板分页查询", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> pageMsgTemplate(@CurrentUser UserBean userBean, @RequestBody AdminMsgTemplateDto search) {
search.setOrgCode(userBean.getOrgCode());
Page<FixedSalaryStaffDto> page = new Page<FixedSalaryStaffDto>(
search.getCurrentPage() == null ? 1 : search.getCurrentPage(),
search.getTotalPage() == null ? 10 : search.getTotalPage());
long total = msgTemplateMapper.pageMsgTemplateCount(search);
List<AdminMsgTemplate> list = msgTemplateMapper.pageMsgTemplate(search);
page.setTotal(total);
return ResultUtil.data(page, list, "消息模板分页查询");
}
@PostMapping("/getMsgTemplate/{id}")
@ApiOperation(value = "根据ID获取消息模板", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> pageMsgTemplate(@CurrentUser UserBean userBean, @PathVariable Integer id) {
return ResultUtil.data(msgTemplateMapper.selectById(id));
}
@PostMapping("/delMsgTemplate/{id}")
@ApiOperation(value = "根据ID删除消息模板", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> delMsgTemplate(@CurrentUser UserBean userBean, @PathVariable Integer id) {
msgTemplateMapper.deleteById(id);
return ResultUtil.success("删除成功");
}
@PostMapping("/editMsgTemplate")
@ApiOperation(value = "新增/编辑消息模板", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> editMsgTemplate(@CurrentUser UserBean userBean, @RequestBody AdminMsgTemplate temp) {
AdminMsgTemplate exits = AdminMsgTemplate.builder().build().selectOne(
new LambdaQueryWrapper<AdminMsgTemplate>().eq(AdminMsgTemplate::getOrgCode, userBean.getOrgCode())
.eq(AdminMsgTemplate::getPlatformNum, temp.getPlatformNum())
.eq(AdminMsgTemplate::getPlatformType, temp.getPlatformType())
.eq(AdminMsgTemplate::getState, 0)
);
if (Objects.nonNull(exits)) {
if (Objects.isNull(temp.getId()) ||
(Objects.nonNull(temp.getId()) && !temp.getId().equals(exits.getId()))) {
return ResultUtil.error("对应平台编号已经存在!");
}
}
temp.setOrgCode(userBean.getOrgCode());
temp.setAddtime(new Date().getTime());
if (Objects.isNull(temp.getId())) {
msgTemplateMapper.insert(temp);
} else {
msgTemplateMapper.updateById(temp);
}
return ResultUtil.success("保存成功");
}
}
......@@ -20,8 +20,21 @@ import java.util.List;
public interface AdminMsgTemplateMapper extends BaseMapper<AdminMsgTemplate> {
/**
* 查询模板
* @param params
* @param param
* @return
*/
List<AdminMsgTemplate> listMsgTemplate(@Param("params") AdminMsgTemplateDto params);
List<AdminMsgTemplate> listMsgTemplate(@Param("param") AdminMsgTemplateDto param);
/**
* 分页查询总数
* @param param
* @return
*/
Long pageMsgTemplateCount(@Param("param") AdminMsgTemplateDto param);
/**
* 分页查询
* @param param
* @return
*/
List<AdminMsgTemplate> pageMsgTemplate(@Param("param") AdminMsgTemplateDto param);
}
......@@ -13,10 +13,6 @@ import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
public class AdminMsgTemplateDto extends Page implements Serializable {
@ApiModelProperty(value="模板编号 ",example="模板ID")
private String templateNum;
@ApiModelProperty(value="模板名称 ",example="模板名称")
private String templateName;
......
......@@ -5,7 +5,6 @@
<resultMap id="BaseResultMap" type="cn.timer.api.bean.admin.AdminMsgTemplate" >
<id column="id" property="id" />
<result column="template_num" property="templateNum" />
<result column="template_name" property="templateName" />
<result column="platform_num" property="platformNum" />
<result column="platform_type" property="platformType" />
......@@ -18,7 +17,6 @@
<sql id="Base_Column_List">
id,
template_num,
template_name,
platform_num,
platform_type,
......@@ -33,21 +31,52 @@
SELECT <include refid="Base_Column_List" />
FROM admin_msg_template temp
<where>
<if test="params.templateName != null and params.templateName !=''">
and temp.template_name like CONCAT('%',#{params.templateName},'%')
<if test="param.templateName != null and param.templateName !=''">
and temp.template_name like CONCAT('%',#{param.templateName},'%')
</if>
<if test="params.platformType != null">
and temp.platform_type = #{params.platformType}
<if test="param.platformType != null">
and temp.platform_type = #{param.platformType}
</if>
<if test="params.msgType != null">
and temp.msg_type = #{params.msgType}
<if test="param.msgType != null">
and temp.msg_type = #{param.msgType}
</if>
<if test="params.state != null">
and temp.state = #{params.state}
<if test="param.state != null">
and temp.state = #{param.state}
</if>
<if test="params.orgCode != null">
and temp.org_code = #{params.orgCode}
<if test="param.orgCode != null">
and temp.org_code = #{param.orgCode}
</if>
</where>
</select>
<!-- 分页查询 -->
<sql id="pageMsgTemplateCondition">
<where>
<if test="param.templateName != null and param.templateName !=''">
and temp.template_name like CONCAT('%',#{param.templateName},'%')
</if>
<if test="param.platformType != null">
and temp.platform_type = #{param.platformType}
</if>
<if test="param.msgType != null">
and temp.msg_type = #{param.msgType}
</if>
<if test="param.state != null">
and temp.state = #{param.state}
</if>
<if test="param.orgCode != null">
and temp.org_code = #{param.orgCode}
</if>
</where>
</sql>
<select id="pageMsgTemplateCount" resultType="java.lang.Long">
SELECT count(*) FROM admin_msg_template temp
<include refid="pageMsgTemplateCondition" />
</select>
<select id="pageMsgTemplate" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM admin_msg_template temp
<include refid="pageMsgTemplateCondition" />
LIMIT #{param.offset}, #{param.totalPage}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment