Java调用Midjourney进行AI画图原生版抓包实现支持中文( 四 )


package com.example.midjourney.service;import com.example.midjourney.bean.pojo.MidjourneyLog;import com.example.midjourney.bean.pojo.RoomInfo;import java.util.List;public interface MidjourneyLogService {MidjourneyLog findById(Long id);MidjourneyLog findLastNormalLog(Integer memberId);MidjourneyLog findLastNormalOrIterative(Integer memberId);void updateRoom(MidjourneyLog midjourneyLog, RoomInfo roomInfo);List selectAllDoing();void updateFail(MidjourneyLog midjourneyLog);void updateSensitive(MidjourneyLog midjourneyLog);void updatePrompt(MidjourneyLog midjourneyLog, String prompt);void updateFinish(MidjourneyLog midjourey);int selectRoomOnUse(Integer id);}
Impl
package com.example.midjourney.service.impl;import com.example.midjourney.bean.pojo.MidjourneyLog;import com.example.midjourney.bean.pojo.RoomInfo;import com.example.midjourney.mapper.MidjourneyLogMapper;import com.example.midjourney.service.MidjourneyLogService;import com.example.midjourney.util.Safes;import org.springframework.stereotype.Service;import javax.annotation.Resource;import java.util.List;@Servicepublic class MidjourneyLogServiceImpl implements MidjourneyLogService {@Resourceprivate MidjourneyLogMapper midjourneyLogMapper;@Overridepublic MidjourneyLog findById(Long id) {return midjourneyLogMapper.selectByPrimaryKey(id);}@Overridepublic MidjourneyLog findLastNormalLog(Integer memberId) {return midjourneyLogMapper.findLastNormalLog(memberId);}@Overridepublic MidjourneyLog findLastNormalOrIterative(Integer memberId) {return midjourneyLogMapper.findLastNormalOrIterative(memberId);}@Overridepublic void updateRoom(MidjourneyLog midjourneyLog, RoomInfo roomInfo) {midjourneyLog.setRoomId(roomInfo.getId());midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic List selectAllDoing() {MidjourneyLog midjourneyLog = new MidjourneyLog();midjourneyLog.setStatus(0);return Safes.of(midjourneyLogMapper.select(midjourneyLog));}@Overridepublic void updateFail(MidjourneyLog midjourneyLog) {midjourneyLog.setStatus(500);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updateSensitive(MidjourneyLog midjourneyLog) {midjourneyLog.setStatus(-1);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updatePrompt(MidjourneyLog midjourneyLog, String prompt) {midjourneyLog.setPrompt(prompt);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updateFinish(MidjourneyLog midjourey) {midjourey.setStatus(1);midjourneyLogMapper.updateByPrimaryKeySelective(midjourey);}@Overridepublic int selectRoomOnUse(Integer id) {return midjourneyLogMapper.selectRoomOnUse(id);}}
这里用了通用插件
package com.example.midjourney.mapper;import com.example.midjourney.bean.pojo.MidjourneyLog;import org.apache.ibatis.annotations.Param;import org.apache.ibatis.annotations.Select;import tk.mybatis.mapper.common.Mapper;public interface MidjourneyLogMapper extends Mapper {String COLUMN = " id, member_id AS memberId, prompt, channel, type, " +"status, img_file AS imgFile, room_id AS roomId ";@Select("SELECT " + COLUMN + " FROM midjourney_log WHERE member_id = #{memberId} AND type = 0 ORDER BY id DESC LIMIT 1")MidjourneyLog findLastNormalLog(@Param("memberId") Integer memberId);@Select("SELECT " + COLUMN + " FROM midjourney_log WHERE member_id = #{memberId} AND (type = 0 OR type = 2)" +" ORDER BY id DESC LIMIT 1")MidjourneyLog findLastNormalOrIterative(Integer memberId);@Select("SELECT COUNT(*) AS count FROM midjourney_log WHERE room_id = #{id} AND status = 0")Integer selectRoomOnUse(@Param("id") Integer id);}
常量类可以根据需要自定调整敏感词
敏感词写上审核不过 , 大家自己想想脑补下吧 , 各种不好的词都往那个敏感词List里面自己加吧!