| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | |
| | | @RestController |
| | | @RequestMapping("/mark") |
| | | public class MarkController extends BaseController { |
| | | @Autowired |
| | | @Resource |
| | | MarkService markService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | BaseUploadService baseUploadService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownlogService downlogService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownloadService downloadService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<MarkEntity>> selectByPageAndCount(Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | public ResponseMsg<List<MarkEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | int count = markService.selectCount(ue.getId()); |
| | | int count = markService.selectCount(name, ue.getId()); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MarkEntity> rs = markService.selectByPage(ue.getId(), pageSize, pageSize * (pageIndex - 1)); |
| | | List<MarkEntity> rs = markService.selectByPage(name, ue.getId(), pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectById") |
| | | public ResponseMsg<MarkEntity> selectById(int id) { |
| | | public ResponseMsg<MarkEntity> selectById(int id, HttpServletRequest req) { |
| | | try { |
| | | MarkEntity entity = markService.selectById(id); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | MarkEntity entity = markService.selectById(id, ue.getId()); |
| | | |
| | | return success(entity); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int id) { |
| | | public ResponseMsg<Integer> delete(int id, HttpServletRequest req) { |
| | | try { |
| | | int count = markService.delete(id); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | int count = markService.delete(id, ue.getId()); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2") |
| | | }) |
| | | @GetMapping(value = "/deletes") |
| | | public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { |
| | | public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | int count = markService.deletes(ids); |
| | | int count = markService.deletes(ids, ue.getId()); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param uid 用户ID |
| | | * @param name 名称 |
| | | * @param userid 用户ID |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer uid); |
| | | public Integer selectCount(String name, Integer userid); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param uid 用户ID |
| | | * @param name 名称 |
| | | * @param userid 用户ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<MarkEntity> selectByPage(Integer uid, Integer limit, Integer offset); |
| | | public List<MarkEntity> selectByPage(String name, Integer userid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @param userid |
| | | * @return |
| | | */ |
| | | public List<MarkEntity> selectAll(); |
| | | public List<MarkEntity> selectAll(Integer userid); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @param userid |
| | | * @return |
| | | */ |
| | | public MarkEntity selectById(int id); |
| | | public MarkEntity selectById(int id, Integer userid); |
| | | |
| | | /** |
| | | * 插入一条 |
| | |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @param userid |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | public Integer delete(int id, Integer userid); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @param userid |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | public Integer deletes(List<Integer> ids, Integer userid); |
| | | |
| | | /** |
| | | * 更新一条 |
| | |
| | | import com.moon.server.mapper.show.MarkMapper; |
| | | import com.moon.server.service.data.DownloadService; |
| | | import com.moon.server.helper.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | */ |
| | | @Service |
| | | public class MarkService implements MarkMapper { |
| | | @Autowired |
| | | @Resource |
| | | MarkMapper markMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownloadService downloadService; |
| | | |
| | | @Override |
| | | public Integer selectCount(Integer uid) { |
| | | return markMapper.selectCount(uid); |
| | | public Integer selectCount(String name, Integer userid) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return markMapper.selectCount(name, userid); |
| | | } |
| | | |
| | | @Override |
| | | public List<MarkEntity> selectByPage(Integer uid, Integer limit, Integer offset) { |
| | | return markMapper.selectByPage(uid, limit, offset); |
| | | public List<MarkEntity> selectByPage(String name, Integer userid, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return markMapper.selectByPage(name, userid, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public List<MarkEntity> selectAll() { |
| | | return markMapper.selectAll(); |
| | | public List<MarkEntity> selectAll(Integer userid) { |
| | | return markMapper.selectAll(userid); |
| | | } |
| | | |
| | | @Override |
| | | public MarkEntity selectById(int id) { |
| | | return markMapper.selectById(id); |
| | | public MarkEntity selectById(int id, Integer userid) { |
| | | return markMapper.selectById(id, userid); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer delete(int id) { |
| | | return markMapper.delete(id); |
| | | public Integer delete(int id, Integer userid) { |
| | | return markMapper.delete(id, userid); |
| | | } |
| | | |
| | | @Override |
| | | public Integer deletes(List<Integer> ids) { |
| | | return markMapper.deletes(ids); |
| | | public Integer deletes(List<Integer> ids, Integer userid) { |
| | | return markMapper.deletes(ids, userid); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_mark |
| | | <where> |
| | | 1 = 1 |
| | | <if test="name != null"> |
| | | and upper(name) like #{name} |
| | | </if> |
| | | <if test="userid != null"> |
| | | create_user = #{userid} |
| | | and create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | <select id="selectByPage" resultType="com.moon.server.entity.show.MarkEntity"> |
| | | select * from lf.sys_mark |
| | | <where> |
| | | 1 = 1 |
| | | <if test="name != null"> |
| | | and upper(name) like #{name} |
| | | </if> |
| | | <if test="userid != null"> |
| | | and create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | order by id desc |
| | | limit #{limit} offset #{offset}; |
| | | </select> |
| | | |
| | | <select id="selectAll" resultType="com.moon.server.entity.show.MarkEntity"> |
| | | select * from lf.sys_mark |
| | | <where> |
| | | <if test="userid != null"> |
| | | create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | order by id desc |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectAll" resultType="com.moon.server.entity.show.MarkEntity"> |
| | | select * from lf.sys_mark order by id desc |
| | | order by id desc; |
| | | </select> |
| | | |
| | | <select id="selectById" resultType="com.moon.server.entity.show.MarkEntity"> |
| | | select * from lf.sys_mark where id = #{id} |
| | | select * from lf.sys_mark |
| | | <where> |
| | | id = #{id} |
| | | <if test="userid != null"> |
| | | and create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <insert id="insert" parameterType="com.moon.server.entity.show.MarkEntity"> |
| | |
| | | </insert> |
| | | |
| | | <delete id="delete"> |
| | | delete from lf.sys_mark where id = #{id} |
| | | delete from lf.sys_mark |
| | | <where> |
| | | id = #{id} |
| | | <if test="userid != null"> |
| | | and create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | </delete> |
| | | |
| | | <delete id="deletes"> |
| | | delete from lf.sys_mark where id in |
| | | <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | delete from lf.sys_mark |
| | | <where> |
| | | id in |
| | | <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | <if test="userid != null"> |
| | | and create_user = #{userid} |
| | | </if> |
| | | </where> |
| | | </delete> |
| | | |
| | | <update id="update"> |
| | | update lf.sys_mark |
| | | set name=#{name},wkt=#{wkt},update_user=#{updateUser},update_time=now() |
| | | where id=#{id} |
| | | where create_user = #{createUser} and id = #{id}; |
| | | </update> |
| | | |
| | | <update id="updates"> |
| | |
| | | <set> |
| | | name=#{item.name},wkt=#{item.wkt},update_user=#{item.updateUser},update_time=now() |
| | | </set> |
| | | where id = #{item.id} |
| | | where create_user = #{createUser} and id = #{item.id}; |
| | | </foreach> |
| | | </update> |
| | | </mapper> |